Allow to set command count also from input box.
authorDaniel Carl <danielcarl@gmx.de>
Thu, 18 Oct 2012 21:00:57 +0000 (23:00 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Thu, 18 Oct 2012 21:00:57 +0000 (23:00 +0200)
src/command.c
src/keybind.c
src/main.c
src/main.h

index 50f7c27..2ab0ab6 100644 (file)
@@ -52,5 +52,9 @@ gboolean command_run(const gchar* name, const gchar* param)
     c->function(&a);
     g_free(a.s);
 
+    /* if command was run, remove the modkey and count */
+    vp.state.modkey = vp.state.count = 0;
+    vp_update_statusbar();
+
     return TRUE;
 }
index 3aa00e4..729b2ce 100644 (file)
@@ -27,7 +27,7 @@ void keybind_add(int mode, guint modkey, guint modmask, guint keyval, const gcha
 
     keys = g_slist_prepend(keys, keybind);
 
-     /* save the modkey also in the modkey string */
+    /* save the modkey also in the modkey string */
     if (modkey) {
         g_string_append_c(modkeys, modkey);
     }
@@ -108,10 +108,6 @@ static gboolean keybind_keypress_callback(WebKitWebView* webview, GdkEventKey* e
         Keybind* keybind = (Keybind*)link->data;
         command_run(keybind->command, NULL);
 
-        /* if key binding used, remove the modkey */
-        vp.state.modkey = vp.state.count = 0;
-        vp_update_statusbar();
-
         return TRUE;
     }
 
index b875a91..5e2085b 100644 (file)
@@ -109,6 +109,7 @@ static gboolean vp_process_input(const char* input)
 {
     gboolean success;
     gchar* line = g_strdup(input);
+    gchar* command = NULL;
     gchar** token;
 
     if (!input || !strlen(input)) {
@@ -117,8 +118,11 @@ static gboolean vp_process_input(const char* input)
 
     g_strstrip(line);
 
+    /* get a possible command count */
+    vp.state.count = g_ascii_strtoll(line, &command, 10);
+
     /* split the input string into command and parameter part */
-    token = g_strsplit(line, " ", 2);
+    token = g_strsplit(command, " ", 2);
     g_free(line);
 
     if (!token[0]) {
index 5aebf64..ac11121 100644 (file)
@@ -104,7 +104,7 @@ typedef struct {
 typedef struct {
     Mode          mode;
     gchar         modkey;
-    int           count;
+    guint         count;
 } State;
 
 /* behaviour */