Allow to use count for search (#6).
authorDaniel Carl <danielcarl@gmx.de>
Sat, 9 Feb 2013 17:18:25 +0000 (18:18 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 9 Feb 2013 17:18:25 +0000 (18:18 +0100)
doc/vimp.1.txt
src/command.c
src/keybind.c
src/main.c
src/main.h

index a6de7b4..aa0cc74 100644 (file)
@@ -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
index f14a77f..36e26bd 100644 (file)
@@ -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;
index 3806c8a..dcd06eb 100644 (file)
@@ -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 */
index 4eb89be..f2f7fea 100644 (file)
@@ -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));
index 552501e..5593bc8 100644 (file)
@@ -230,9 +230,7 @@ typedef struct {
 
 /* behaviour */
 typedef struct {
-    /* command list: (key)name -> (value)Command  */
     GHashTable* commands;
-    /* keybindings */
     GSList*     keys;
     GString*    modkeys;
 } Behaviour;