Add keybindings for Find Usage, Go to definition/declaration, based on the current cursor position. Also ensure null termination in utils_find_current_word
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@456 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
7b0f931a2f
commit
e07a1a8387
10
ChangeLog
10
ChangeLog
@ -4,9 +4,13 @@
|
||||
doc/geany.docbook: Made Duplicate Line command duplicate selection
|
||||
if present.
|
||||
* src/highlighting.c: Fixed styling for unmatched braces.
|
||||
* src/keybindings.c, src/keybindings.h, doc/geany.docbook:
|
||||
Set default keybindings for switch page left/right; also group
|
||||
toggle sidebar keybinding with toggle messages.
|
||||
* src/keybindings.h, doc/geany.docbook:
|
||||
Group toggle sidebar keybinding with toggle messages.
|
||||
* src/keybindings.c: Set keyboard shortcuts for switching tab pages.
|
||||
* src/keybindings.c, src/keybindings.h:
|
||||
Add keybindings for Find Usage, Go to definition/declaration,
|
||||
based on the current cursor position.
|
||||
* src/utils.c: Ensure null termination in utils_find_current_word.
|
||||
|
||||
|
||||
2006-06-16 Enrico Troeger <enrico.troeger@uvena.de>
|
||||
|
||||
@ -84,7 +84,11 @@ static void cb_func_edit_autocomplete(void);
|
||||
static void cb_func_edit_calltip(void);
|
||||
static void cb_func_edit_macrolist(void);
|
||||
static void cb_func_edit_suppresscompletion(void);
|
||||
static void cb_func_popup_findusage(void);
|
||||
static void cb_func_popup_gototagdefinition(void);
|
||||
static void cb_func_popup_gototagdeclaration(void);
|
||||
|
||||
void keybindings_call_popup_item(int menuitemkey);
|
||||
void keybindings_add_accels();
|
||||
|
||||
|
||||
@ -139,6 +143,12 @@ void keybindings_init(void)
|
||||
keys[GEANY_KEYS_EDIT_CALLTIP] = fill(cb_func_edit_calltip, GDK_space, GDK_MOD1_MASK, "edit_calltip", _("Show calltip"));
|
||||
keys[GEANY_KEYS_EDIT_MACROLIST] = fill(cb_func_edit_macrolist, GDK_Return, GDK_CONTROL_MASK, "edit_macrolist", _("Show macro list"));
|
||||
keys[GEANY_KEYS_EDIT_SUPPRESSCOMPLETION] = fill(cb_func_edit_suppresscompletion, GDK_space, GDK_SHIFT_MASK, "edit_suppresscompletion", _("Suppress auto completion"));
|
||||
keys[GEANY_KEYS_POPUP_FINDUSAGE] = fill(cb_func_popup_findusage,
|
||||
0, 0, "popup_findusage", _("Find Usage"));
|
||||
keys[GEANY_KEYS_POPUP_GOTOTAGDEFINITION] = fill(cb_func_popup_gototagdefinition,
|
||||
0, 0, "popup_gototagdefinition", _("Go to tag definition"));
|
||||
keys[GEANY_KEYS_POPUP_GOTOTAGDECLARATION] = fill(cb_func_popup_gototagdeclaration,
|
||||
0, 0, "popup_gototagdeclaration", _("Go to tag declaration"));
|
||||
|
||||
// now load user defined keys
|
||||
if (g_key_file_load_from_file(config, configfile, G_KEY_FILE_KEEP_COMMENTS, NULL))
|
||||
@ -170,6 +180,13 @@ void keybindings_init(void)
|
||||
"activate", accel_group, keys[(gkey)]->key, keys[(gkey)]->mods, \
|
||||
GTK_ACCEL_VISIBLE)
|
||||
|
||||
#define GEANY_ADD_POPUP_ACCEL(gkey, wid) \
|
||||
if (keys[(gkey)]->key != 0) \
|
||||
gtk_widget_add_accelerator( \
|
||||
lookup_widget(app->popup_menu, G_STRINGIFY(wid)), \
|
||||
"activate", accel_group, keys[(gkey)]->key, keys[(gkey)]->mods, \
|
||||
GTK_ACCEL_VISIBLE)
|
||||
|
||||
void keybindings_add_accels()
|
||||
{
|
||||
GtkAccelGroup *accel_group = gtk_accel_group_new();
|
||||
@ -192,6 +209,10 @@ void keybindings_add_accels()
|
||||
GEANY_ADD_ACCEL(GEANY_KEYS_MENU_FOLDALL, menu_fold_all1);
|
||||
GEANY_ADD_ACCEL(GEANY_KEYS_MENU_UNFOLDALL, menu_unfold_all1);
|
||||
|
||||
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_POPUP_FINDUSAGE, find_usage1);
|
||||
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_POPUP_GOTOTAGDEFINITION, goto_tag_definition1);
|
||||
GEANY_ADD_POPUP_ACCEL(GEANY_KEYS_POPUP_GOTOTAGDECLARATION, goto_tag_declaration1);
|
||||
|
||||
// the build menu items are set if the build menus are created
|
||||
|
||||
gtk_window_add_accel_group(GTK_WINDOW(app->window), accel_group);
|
||||
@ -453,6 +474,54 @@ static void cb_func_reloadtaglist(void)
|
||||
document_update_tag_list(idx, TRUE);
|
||||
}
|
||||
|
||||
|
||||
static void cb_func_popup_findusage(void)
|
||||
{
|
||||
keybindings_call_popup_item(GEANY_KEYS_POPUP_FINDUSAGE);
|
||||
}
|
||||
|
||||
|
||||
static void cb_func_popup_gototagdefinition(void)
|
||||
{
|
||||
keybindings_call_popup_item(GEANY_KEYS_POPUP_GOTOTAGDEFINITION);
|
||||
}
|
||||
|
||||
|
||||
static void cb_func_popup_gototagdeclaration(void)
|
||||
{
|
||||
keybindings_call_popup_item(GEANY_KEYS_POPUP_GOTOTAGDECLARATION);
|
||||
}
|
||||
|
||||
|
||||
void keybindings_call_popup_item(int menuitemkey)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
gint pos = sci_get_current_position(doc_list[idx].sci);
|
||||
gchar current_word[128];
|
||||
|
||||
utils_find_current_word(doc_list[idx].sci, pos,
|
||||
current_word, sizeof current_word);
|
||||
|
||||
if (*current_word == 0)
|
||||
utils_beep();
|
||||
else
|
||||
switch (menuitemkey)
|
||||
{
|
||||
case GEANY_KEYS_POPUP_FINDUSAGE:
|
||||
on_find_usage1_activate(NULL, NULL);
|
||||
break;
|
||||
case GEANY_KEYS_POPUP_GOTOTAGDEFINITION:
|
||||
on_goto_tag_activate(GTK_MENU_ITEM(lookup_widget(app->popup_menu,
|
||||
"goto_tag_definition1")), NULL);
|
||||
break;
|
||||
case GEANY_KEYS_POPUP_GOTOTAGDECLARATION:
|
||||
on_goto_tag_activate(GTK_MENU_ITEM(lookup_widget(app->popup_menu,
|
||||
"goto_tag_declaration1")), NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void cb_func_switch_editor(void)
|
||||
{
|
||||
gint idx = document_get_cur_idx();
|
||||
|
||||
@ -82,6 +82,9 @@ enum
|
||||
GEANY_KEYS_EDIT_CALLTIP,
|
||||
GEANY_KEYS_EDIT_MACROLIST,
|
||||
GEANY_KEYS_EDIT_SUPPRESSCOMPLETION,
|
||||
GEANY_KEYS_POPUP_FINDUSAGE,
|
||||
GEANY_KEYS_POPUP_GOTOTAGDEFINITION,
|
||||
GEANY_KEYS_POPUP_GOTOTAGDECLARATION,
|
||||
GEANY_MAX_KEYS
|
||||
};
|
||||
|
||||
|
||||
@ -1066,7 +1066,7 @@ void utils_find_current_word(ScintillaObject *sci, gint pos, gchar *word, size_t
|
||||
|
||||
chunk[endword] = '\0';
|
||||
|
||||
strncpy(word, chunk + startword, MIN(endword - startword + 1, wordlen));
|
||||
g_strlcpy(word, chunk + startword, wordlen); //ensure null terminated
|
||||
g_free(chunk);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user