From: Daniel Carl Date: Sat, 9 Feb 2013 17:18:25 +0000 (+0100) Subject: Allow to use count for search (#6). X-Git-Url: https://git.owens.tech/git.owens.tech/git.owens.tech/git?a=commitdiff_plain;h=58f503b391ee437dd5d4caf14c72479bc89895d1;p=vimb.git Allow to use count for search (#6). --- diff --git a/doc/vimp.1.txt b/doc/vimp.1.txt index a6de7b4..aa0cc74 100644 --- a/doc/vimp.1.txt +++ b/doc/vimp.1.txt @@ -244,7 +244,7 @@ Yank the selected text into the primary and secondary clipboard. .B set Set configuration values. .TP -.B search-{forward, backward} +.IB [N] search-{forward, backward} Search in current page forward or backward. .TP .B inspect diff --git a/src/command.c b/src/command.c index f14a77f..36e26bd 100644 --- a/src/command.c +++ b/src/command.c @@ -388,7 +388,11 @@ gboolean command_search(const Arg* arg) webkit_web_view_mark_text_matches(vp.gui.webview, state->search_query, FALSE, 0); webkit_web_view_set_highlight_text_matches(vp.gui.webview, TRUE); #endif - webkit_web_view_search_text(vp.gui.webview, state->search_query, FALSE, forward, TRUE); + /* make sure we have a count greater than 0 */ + vp.state.count = vp.state.count ? vp.state.count : 1; + do { + webkit_web_view_search_text(vp.gui.webview, state->search_query, FALSE, forward, TRUE); + } while (--vp.state.count); } return TRUE; diff --git a/src/keybind.c b/src/keybind.c index 3806c8a..dcd06eb 100644 --- a/src/keybind.c +++ b/src/keybind.c @@ -251,7 +251,7 @@ static gboolean keybind_keypress_callback(WebKitWebView* webview, GdkEventKey* e return TRUE; } /* allow mode keys and counts only in normal mode */ - if (VP_MODE_NORMAL == vp.state.mode) { + if ((VP_MODE_SEARCH | VP_MODE_NORMAL) & vp.state.mode) { if (vp.state.modkey == 0 && ((keyval >= GDK_1 && keyval <= GDK_9) || (keyval == GDK_0 && vp.state.count))) { /* append the new entered count to previous one */ diff --git a/src/main.c b/src/main.c index 4eb89be..f2f7fea 100644 --- a/src/main.c +++ b/src/main.c @@ -471,9 +471,6 @@ gboolean vp_set_mode(Mode mode, gboolean clean) gtk_widget_grab_focus(GTK_WIDGET(vp.gui.webview)); break; - case VP_MODE_SEARCH: - break; - case VP_MODE_COMMAND: case VP_MODE_HINTING: gtk_widget_grab_focus(GTK_WIDGET(vp.gui.inputbox)); diff --git a/src/main.h b/src/main.h index 552501e..5593bc8 100644 --- a/src/main.h +++ b/src/main.h @@ -230,9 +230,7 @@ typedef struct { /* behaviour */ typedef struct { - /* command list: (key)name -> (value)Command */ GHashTable* commands; - /* keybindings */ GSList* keys; GString* modkeys; } Behaviour;