Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Sun, 30 Jun 2024 09:45:57 UTC Commit: 2fba3420c51753da1d25e07a128c14d33b23a86f https://github.com/geany/geany/commit/2fba3420c51753da1d25e07a128c14d33b23a8...
Log Message: ----------- Add Geany code delegating symbol goto to plugins
Most of the changes just make it possible for the extension freely decide whether to perform goto based on its internal logic. This moves obtaining the current word and related logic for Geany's TM-based goto into symbols_goto_tag().
Co-authored-by: Colomban Wendling ban@herbesfolles.org
Modified Paths: -------------- src/editor.c src/keybindings.c src/symbols.c src/symbols.h
Modified: src/editor.c 6 lines changed, 1 insertions(+), 5 deletions(-) =================================================================== @@ -317,11 +317,7 @@ static gboolean on_editor_button_press_event(GtkWidget *widget, GdkEventButton * { sci_set_current_position(editor->sci, editor_info.click_pos, FALSE);
- editor_find_current_word(editor, editor_info.click_pos, - current_word, sizeof current_word, NULL); - if (*current_word) - return symbols_goto_tag(current_word, TRUE); - else + if (!symbols_goto_tag(doc, editor_info.click_pos, TRUE)) keybindings_send_command(GEANY_KEY_GROUP_GOTO, GEANY_KEYS_GOTO_MATCHINGBRACE); return TRUE; }
Modified: src/keybindings.c 8 lines changed, 1 insertions(+), 7 deletions(-) =================================================================== @@ -1972,14 +1972,8 @@ static gboolean cb_func_clipboard_action(guint key_id)
static void goto_tag(GeanyDocument *doc, gboolean definition) { - gchar *text = get_current_word_or_sel(doc, FALSE); - - if (text) - symbols_goto_tag(text, definition); - else + if (!symbols_goto_tag(doc, sci_get_current_position(doc->editor->sci), definition)) utils_beep(); - - g_free(text); }
Modified: src/symbols.c 41 lines changed, 32 insertions(+), 9 deletions(-) =================================================================== @@ -46,6 +46,7 @@ #include "highlighting.h" #include "main.h" #include "navqueue.h" +#include "pluginextension.h" #include "sciwrappers.h" #include "sidebar.h" #include "support.h" @@ -1686,19 +1687,41 @@ static gboolean goto_tag(const gchar *name, gboolean definition) }
-gboolean symbols_goto_tag(const gchar *name, gboolean definition) +gboolean symbols_goto_tag(GeanyDocument *doc, gint pos, gboolean definition) { - if (goto_tag(name, definition)) - return TRUE; + gchar *name; + gboolean success;
- /* if we are here, there was no match and we are beeping ;-) */ - utils_beep(); + if (plugin_extension_goto_provided(doc, NULL)) + return plugin_extension_goto_perform(doc, pos, definition);
- if (!definition) - ui_set_statusbar(FALSE, _("Forward declaration "%s" not found."), name); + /* get the current selection if any, or current word */ + if (sci_has_selection(doc->editor->sci)) + name = sci_get_selection_contents(doc->editor->sci); else - ui_set_statusbar(FALSE, _("Definition of "%s" not found."), name); - return FALSE; + { + editor_find_current_word(doc->editor, pos, + editor_info.current_word, GEANY_MAX_WORD_LENGTH, NULL); + name = *editor_info.current_word ? g_strdup(editor_info.current_word) : NULL; + } + + if (!name) + return FALSE; + + if (! (success = goto_tag(name, definition))) + { + /* if we are here, there was no match and we are beeping ;-) */ + utils_beep(); + + if (!definition) + ui_set_statusbar(FALSE, _("Forward declaration "%s" not found."), name); + else + ui_set_statusbar(FALSE, _("Definition of "%s" not found."), name); + } + + g_free(name); + + return success; }
Modified: src/symbols.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -57,7 +57,7 @@ gint symbols_generate_global_tags(gint argc, gchar **argv, gboolean want_preproc
void symbols_show_load_tags_dialog(void);
-gboolean symbols_goto_tag(const gchar *name, gboolean definition); +gboolean symbols_goto_tag(GeanyDocument *doc, gint pos, gboolean definition);
gint symbols_get_current_function(GeanyDocument *doc, const gchar **tagname);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).