[geany/geany] 394b2d: Show correct icons in autocompletion popups

Jiří Techet git-noreply at geany.org
Wed Apr 20 21:23:17 UTC 2022


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Wed, 20 Apr 2022 21:23:17 UTC
Commit:      394b2d3944ca90c32e59d4097c9bc8690b397dca
             https://github.com/geany/geany/commit/394b2d3944ca90c32e59d4097c9bc8690b397dca

Log Message:
-----------
Show correct icons in autocompletion popups

Since we can easily query icons assigned to specific TM types now
(together with having the possibility to change the icons to whatever
we like independently of TM type), we can display the same icon that
is used in the symbol tree and goto symbol definition/declaration
popup for autocompletion too.


Modified Paths:
--------------
    src/editor.c
    src/symbols.c
    src/symbols.h

Modified: src/editor.c
22 lines changed, 15 insertions(+), 7 deletions(-)
===================================================================
@@ -619,6 +619,8 @@ static void show_tags_list(GeanyEditor *editor, const GPtrArray *tags, gsize roo
 		for (j = 0; j < tags->len; ++j)
 		{
 			TMTag *tag = tags->pdata[j];
+			gint group;
+			guint icon_id;
 
 			if (j > 0)
 				g_string_append_c(words, '\n');
@@ -630,11 +632,13 @@ static void show_tags_list(GeanyEditor *editor, const GPtrArray *tags, gsize roo
 			}
 			g_string_append(words, tag->name);
 
-			/* for now, tag types don't all follow C, so just look at arglist */
-			if (!EMPTY(tag->arglist))
-				g_string_append(words, "?2");
-			else
-				g_string_append(words, "?1");
+			group = tm_parser_get_sidebar_group(tag->lang, tag->type);
+			if (group >= 0 && tm_parser_get_sidebar_info(tag->lang, group, &icon_id))
+			{
+				gchar buf[10];
+				sprintf(buf, "?%u", icon_id + 1);
+				g_string_append(words, buf);
+			}
 		}
 		show_autocomplete(sci, rootlen, words);
 		g_string_free(words, TRUE);
@@ -4850,6 +4854,7 @@ static ScintillaObject *create_new_sci(GeanyEditor *editor)
 {
 	ScintillaObject *sci;
 	int rectangular_selection_modifier;
+	guint i;
 
 	sci = SCINTILLA(scintilla_new());
 
@@ -4874,8 +4879,11 @@ static ScintillaObject *create_new_sci(GeanyEditor *editor)
 	SSM(sci, SCI_SETSCROLLWIDTHTRACKING, 1, 0);
 
 	/* tag autocompletion images */
-	register_named_icon(sci, 1, "classviewer-var");
-	register_named_icon(sci, 2, "classviewer-method");
+	for (i = 0; i < TM_N_ICONS; i++)
+	{
+		const gchar *icon_name = symbols_get_icon_name(i);
+		register_named_icon(sci, i + 1, icon_name);
+	}
 
 	/* necessary for column mode editing, implemented in Scintilla since 2.0 */
 	SSM(sci, SCI_SETADDITIONALSELECTIONTYPING, 1, 0);


Modified: src/symbols.c
8 lines changed, 8 insertions(+), 0 deletions(-)
===================================================================
@@ -2023,6 +2023,14 @@ gint symbols_get_current_scope(GeanyDocument *doc, const gchar **tagname)
 }
 
 
+const gchar *symbols_get_icon_name(guint icon_id)
+{
+	if (icon_id < TM_N_ICONS)
+		return symbols_icons[icon_id].icon_name;
+	return NULL;
+}
+
+
 static void on_symbol_tree_sort_clicked(GtkMenuItem *menuitem, gpointer user_data)
 {
 	gint sort_mode = GPOINTER_TO_INT(user_data);


Modified: src/symbols.h
2 lines changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -63,6 +63,8 @@ gint symbols_get_current_function(GeanyDocument *doc, const gchar **tagname);
 
 gint symbols_get_current_scope(GeanyDocument *doc, const gchar **tagname);
 
+const gchar *symbols_get_icon_name(guint icon_id);
+
 #endif /* GEANY_PRIVATE */
 
 G_END_DECLS



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list