Add 'Mark All' keybinding.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3949 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
bb7a91f43e
commit
8c7f40f3f9
@ -3,6 +3,8 @@
|
||||
* src/editor.c:
|
||||
Delay highlighting matching braces by 100ms, which speeds up
|
||||
scrolling with the arrow keys.
|
||||
* src/keybindings.c, src/keybindings.h, src/search.c, src/search.h:
|
||||
Add 'Mark All' keybinding.
|
||||
|
||||
|
||||
2009-07-09 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "treeviews.h"
|
||||
#include "geanywraplabel.h"
|
||||
#include "main.h"
|
||||
#include "search.h"
|
||||
|
||||
|
||||
GPtrArray *keybinding_groups; /* array of GeanyKeyGroup pointers */
|
||||
@ -360,6 +361,8 @@ static void init_default_kb(void)
|
||||
0, 0, "popup_findusage", _("Find Usage"), NULL);
|
||||
keybindings_set_item(group, GEANY_KEYS_SEARCH_FINDDOCUMENTUSAGE, cb_func_search_action,
|
||||
0, 0, "popup_finddocumentusage", _("Find Document Usage"), NULL);
|
||||
keybindings_set_item(group, GEANY_KEYS_SEARCH_MARKALL, cb_func_search_action,
|
||||
GDK_m, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "find_markall", _("Mark All"), NULL);
|
||||
|
||||
group = ADD_KB_GROUP(GOTO, _("Go to"));
|
||||
|
||||
@ -1251,7 +1254,12 @@ static void cb_func_menu_help(G_GNUC_UNUSED guint key_id)
|
||||
|
||||
static void cb_func_search_action(guint key_id)
|
||||
{
|
||||
GeanyDocument *doc;
|
||||
GeanyDocument *doc = document_get_current();
|
||||
ScintillaObject *sci;
|
||||
|
||||
if (!doc)
|
||||
return;
|
||||
sci = doc->editor->sci;
|
||||
|
||||
switch (key_id)
|
||||
{
|
||||
@ -1274,15 +1282,27 @@ static void cb_func_search_action(guint key_id)
|
||||
case GEANY_KEYS_SEARCH_PREVIOUSMESSAGE:
|
||||
on_previous_message1_activate(NULL, NULL); break;
|
||||
case GEANY_KEYS_SEARCH_FINDUSAGE:
|
||||
doc = document_get_current();
|
||||
read_current_word(doc);
|
||||
on_find_usage1_activate(NULL, NULL);
|
||||
break;
|
||||
case GEANY_KEYS_SEARCH_FINDDOCUMENTUSAGE:
|
||||
doc = document_get_current();
|
||||
read_current_word(doc);
|
||||
on_find_document_usage1_activate(NULL, NULL);
|
||||
break;
|
||||
case GEANY_KEYS_SEARCH_MARKALL:
|
||||
if (sci_has_selection(sci))
|
||||
{
|
||||
gchar *text = g_alloca(sci_get_selected_text_length(sci) + 1);
|
||||
|
||||
sci_get_selected_text(sci, text);
|
||||
search_mark_all(doc, text, SCFIND_MATCHCASE);
|
||||
}
|
||||
else
|
||||
{
|
||||
read_current_word(doc);
|
||||
search_mark_all(doc, editor_info.current_word, SCFIND_MATCHCASE | SCFIND_WHOLEWORD);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,6 +206,7 @@ enum
|
||||
GEANY_KEYS_SEARCH_PREVIOUSMESSAGE,
|
||||
GEANY_KEYS_SEARCH_FINDUSAGE,
|
||||
GEANY_KEYS_SEARCH_FINDDOCUMENTUSAGE,
|
||||
GEANY_KEYS_SEARCH_MARKALL,
|
||||
GEANY_KEYS_SEARCH_COUNT
|
||||
};
|
||||
|
||||
|
@ -959,13 +959,16 @@ on_find_replace_checkbutton_toggled(GtkToggleButton *togglebutton, gpointer user
|
||||
}
|
||||
|
||||
|
||||
static gint search_mark(GeanyDocument *doc, const gchar *search_text, gint flags)
|
||||
/* @return Number of matches marked. */
|
||||
gint search_mark_all(GeanyDocument *doc, const gchar *search_text, gint flags)
|
||||
{
|
||||
gint pos, count = 0;
|
||||
gsize len;
|
||||
struct Sci_TextToFind ttf;
|
||||
|
||||
g_return_val_if_fail(doc != NULL, 0);
|
||||
if (!NZV(search_text))
|
||||
return 0;
|
||||
|
||||
/* clear previous search indicators */
|
||||
editor_indicator_clear(doc->editor, GEANY_INDICATOR_SEARCH);
|
||||
@ -1074,7 +1077,7 @@ on_find_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
|
||||
|
||||
case GEANY_RESPONSE_MARK:
|
||||
{
|
||||
gint count = search_mark(doc, search_data.text, search_data.flags);
|
||||
gint count = search_mark_all(doc, search_data.text, search_data.flags);
|
||||
|
||||
if (count == 0)
|
||||
ui_set_statusbar(FALSE, _("No matches found for \"%s\"."), search_data.text);
|
||||
|
@ -65,4 +65,6 @@ void search_find_usage(const gchar *search_text, gint flags, gboolean in_session
|
||||
|
||||
void search_find_selection(GeanyDocument *doc, gboolean search_backwards);
|
||||
|
||||
gint search_mark_all(GeanyDocument *doc, const gchar *search_text, gint flags);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user