Make Goto Tag commands use the current selection if present (useful
for selecting part of a tag or for ReST section names with spaces in). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4195 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
aec081dcf3
commit
4097dfec5b
@ -1,3 +1,11 @@
|
||||
2009-09-16 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||
|
||||
* src/keybindings.c, src/callbacks.c, src/search.c:
|
||||
Make Goto Tag commands use the current selection if present (useful
|
||||
for selecting part of a tag or for ReST section names with spaces
|
||||
in).
|
||||
|
||||
|
||||
2009-09-15 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
|
||||
|
||||
* src/main.c:
|
||||
|
@ -1121,8 +1121,15 @@ on_goto_tag_activate (GtkMenuItem *menuitem,
|
||||
|
||||
g_return_if_fail(doc != NULL);
|
||||
|
||||
sci_set_current_position(doc->editor->sci, editor_info.click_pos, FALSE);
|
||||
symbols_goto_tag(editor_info.current_word, definition);
|
||||
/* update cursor pos for navigating back afterwards */
|
||||
if (!sci_has_selection(doc->editor->sci))
|
||||
sci_set_current_position(doc->editor->sci, editor_info.click_pos, FALSE);
|
||||
|
||||
/* use the keybinding callback as it checks for selections as well as current word */
|
||||
if (definition)
|
||||
keybindings_send_command(GEANY_KEY_GROUP_GOTO, GEANY_KEYS_GOTO_TAGDEFINITION);
|
||||
else
|
||||
keybindings_send_command(GEANY_KEY_GROUP_GOTO, GEANY_KEYS_GOTO_TAGDECLARATION);
|
||||
}
|
||||
|
||||
|
||||
|
@ -80,6 +80,7 @@ static gboolean on_key_release_event(GtkWidget *widget, GdkEventKey *event, gpoi
|
||||
|
||||
static gboolean check_current_word(GeanyDocument *doc);
|
||||
static gboolean read_current_word(GeanyDocument *doc);
|
||||
static gchar *get_current_word_or_sel(GeanyDocument *doc);
|
||||
|
||||
static void cb_func_file_action(guint key_id);
|
||||
static void cb_func_project_action(guint key_id);
|
||||
@ -1340,22 +1341,23 @@ static void cb_func_search_action(guint key_id)
|
||||
on_find_document_usage1_activate(NULL, NULL);
|
||||
break;
|
||||
case GEANY_KEYS_SEARCH_MARKALL:
|
||||
if (sci_has_selection(sci))
|
||||
{
|
||||
gchar *text = sci_get_selection_contents(sci);
|
||||
{
|
||||
gchar *text = get_current_word_or_sel(doc);
|
||||
|
||||
if (sci_has_selection(sci))
|
||||
search_mark_all(doc, text, SCFIND_MATCHCASE);
|
||||
g_free(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
read_current_word(doc);
|
||||
search_mark_all(doc, editor_info.current_word, SCFIND_MATCHCASE | SCFIND_WHOLEWORD);
|
||||
/* clears markers if text is null */
|
||||
search_mark_all(doc, text, SCFIND_MATCHCASE | SCFIND_WHOLEWORD);
|
||||
}
|
||||
g_free(text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void cb_func_menu_opencolorchooser(G_GNUC_UNUSED guint key_id)
|
||||
{
|
||||
on_show_color_chooser1_activate(NULL, NULL);
|
||||
@ -1481,6 +1483,17 @@ static gboolean check_current_word(GeanyDocument *doc)
|
||||
}
|
||||
|
||||
|
||||
static gchar *get_current_word_or_sel(GeanyDocument *doc)
|
||||
{
|
||||
ScintillaObject *sci = doc->editor->sci;
|
||||
|
||||
if (sci_has_selection(sci))
|
||||
return sci_get_selection_contents(sci);
|
||||
|
||||
return read_current_word(doc) ? g_strdup(editor_info.current_word) : NULL;
|
||||
}
|
||||
|
||||
|
||||
static void focus_sidebar(void)
|
||||
{
|
||||
if (ui_prefs.sidebar_visible)
|
||||
@ -1784,6 +1797,19 @@ static void cb_func_clipboard(guint key_id)
|
||||
}
|
||||
|
||||
|
||||
static void goto_tag(GeanyDocument *doc, gboolean definition)
|
||||
{
|
||||
gchar *text = get_current_word_or_sel(doc);
|
||||
|
||||
if (text)
|
||||
symbols_goto_tag(text, definition);
|
||||
else
|
||||
utils_beep();
|
||||
|
||||
g_free(text);
|
||||
}
|
||||
|
||||
|
||||
/* Common function for goto keybindings, useful even when sci doesn't have focus. */
|
||||
static void cb_func_goto_action(guint key_id)
|
||||
{
|
||||
@ -1837,12 +1863,10 @@ static void cb_func_goto_action(guint key_id)
|
||||
return;
|
||||
}
|
||||
case GEANY_KEYS_GOTO_TAGDEFINITION:
|
||||
if (check_current_word(doc))
|
||||
symbols_goto_tag(editor_info.current_word, TRUE);
|
||||
goto_tag(doc, TRUE);
|
||||
return;
|
||||
case GEANY_KEYS_GOTO_TAGDECLARATION:
|
||||
if (check_current_word(doc))
|
||||
symbols_goto_tag(editor_info.current_word, FALSE);
|
||||
goto_tag(doc, FALSE);
|
||||
return;
|
||||
}
|
||||
/* only check editor-sensitive keybindings when editor has focus */
|
||||
|
@ -959,7 +959,8 @@ on_find_replace_checkbutton_toggled(GtkToggleButton *togglebutton, gpointer user
|
||||
}
|
||||
|
||||
|
||||
/* @return Number of matches marked. */
|
||||
/* Clears markers if text is null/empty.
|
||||
* @return Number of matches marked. */
|
||||
gint search_mark_all(GeanyDocument *doc, const gchar *search_text, gint flags)
|
||||
{
|
||||
gint pos, count = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user