diff --git a/doc/geany.txt b/doc/geany.txt index 609f4c7b31..67fe5d4ab9 100644 --- a/doc/geany.txt +++ b/doc/geany.txt @@ -3371,6 +3371,14 @@ Complete word Ctrl-Space Shows the autocompleti Show calltip Ctrl-Shift-Space Shows a calltip for the current function or method. +Show previous calltip If there are multiple matching tags, shows + the calltip for the previous one (same as clicking + on the up arrow in the calltip). + +Show next calltip If there are multiple matching tags, shows + the calltip for the next one (same as clicking on + the down arrow in the calltip). + Complete snippet Tab If you type a construct like if or for and press this key, it will be completed with a matching template. diff --git a/src/editor.c b/src/editor.c index 7d7131d81a..7c4847743e 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1183,12 +1183,8 @@ static gboolean on_editor_notify(G_GNUC_UNUSED GObject *object, GeanyEditor *edi { switch (nt->position) { - case 1: /* up arrow */ - if (calltip.tag_index > 0) - calltip.tag_index--; - break; - - case 2: calltip.tag_index++; break; /* down arrow */ + case 1: editor_prev_calltip(); break; /* up arrow */ + case 2: editor_next_calltip(); break; /* down arrow */ } editor_show_calltip(editor, -1); } @@ -2062,6 +2058,20 @@ gboolean editor_show_calltip(GeanyEditor *editor, gint pos) } +void editor_prev_calltip(void) +{ + if (calltip.tag_index > 0) + calltip.tag_index -= 1; +} + + +void editor_next_calltip(void) +{ + /* Will be clipped into range by find_calltip(). */ + calltip.tag_index += 1; +} + + gchar *editor_get_calltip_text(GeanyEditor *editor, const TMTag *tag) { GString *str; diff --git a/src/editor.h b/src/editor.h index 696334ebc8..35fb950e0f 100644 --- a/src/editor.h +++ b/src/editor.h @@ -242,6 +242,10 @@ gboolean editor_complete_snippet(GeanyEditor *editor, gint pos); gboolean editor_show_calltip(GeanyEditor *editor, gint pos); +void editor_prev_calltip(void); + +void editor_next_calltip(void); + void editor_do_comment_toggle(GeanyEditor *editor); gint editor_do_comment(GeanyEditor *editor, gint line, gboolean allow_empty_lines, gboolean toggle, diff --git a/src/keybindings.c b/src/keybindings.c index 905e8798da..ed760ef045 100644 --- a/src/keybindings.c +++ b/src/keybindings.c @@ -410,6 +410,10 @@ static void init_default_kb(void) GDK_space, GEANY_PRIMARY_MOD_MASK, "edit_autocomplete", _("Complete word"), NULL); add_kb(group, GEANY_KEYS_EDITOR_CALLTIP, NULL, GDK_space, GEANY_PRIMARY_MOD_MASK | GDK_SHIFT_MASK, "edit_calltip", _("Show calltip"), NULL); + add_kb(group, GEANY_KEYS_EDITOR_PREVCALLTIP, NULL, + 0, 0, "edit_prevcalltip", _("Show previous calltip"), NULL); + add_kb(group, GEANY_KEYS_EDITOR_NEXTCALLTIP, NULL, + 0, 0, "edit_nextcalltip", _("Show next calltip"), NULL); add_kb(group, GEANY_KEYS_EDITOR_WORDPARTCOMPLETION, NULL, GDK_Tab, 0, "edit_wordpartcompletion", _("Word part completion"), NULL); add_kb(group, GEANY_KEYS_EDITOR_MOVELINEUP, NULL, @@ -2149,6 +2153,14 @@ static gboolean cb_func_editor_action(guint key_id) case GEANY_KEYS_EDITOR_CALLTIP: editor_show_calltip(doc->editor, -1); break; + case GEANY_KEYS_EDITOR_PREVCALLTIP: + editor_prev_calltip(); + editor_show_calltip(doc->editor, -1); + break; + case GEANY_KEYS_EDITOR_NEXTCALLTIP: + editor_next_calltip(); + editor_show_calltip(doc->editor, -1); + break; case GEANY_KEYS_EDITOR_CONTEXTACTION: if (check_current_word(doc, FALSE)) on_context_action1_activate(GTK_MENU_ITEM(ui_lookup_widget(main_widgets.editor_menu, diff --git a/src/keybindings.h b/src/keybindings.h index aa2afef096..42cc6b4e7f 100644 --- a/src/keybindings.h +++ b/src/keybindings.h @@ -274,6 +274,8 @@ enum GeanyKeyBindingID GEANY_KEYS_FORMAT_SENDTOCMD8, /**< Keybinding. */ GEANY_KEYS_FORMAT_SENDTOCMD9, /**< Keybinding. */ GEANY_KEYS_EDITOR_DELETELINETOBEGINNING, /**< Keybinding. */ + GEANY_KEYS_EDITOR_PREVCALLTIP, /**< Keybinding. */ + GEANY_KEYS_EDITOR_NEXTCALLTIP, /**< Keybinding. */ GEANY_KEYS_COUNT /* must not be used by plugins */ };