From 3e8c358a11983f968e1c7cef36022975d495066c Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Thu, 18 Oct 2012 23:00:57 +0200 Subject: [PATCH] Allow to set command count also from input box. --- src/command.c | 4 ++++ src/keybind.c | 6 +----- src/main.c | 6 +++++- src/main.h | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/command.c b/src/command.c index 50f7c27..2ab0ab6 100644 --- a/src/command.c +++ b/src/command.c @@ -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; } diff --git a/src/keybind.c b/src/keybind.c index 3aa00e4..729b2ce 100644 --- a/src/keybind.c +++ b/src/keybind.c @@ -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; } diff --git a/src/main.c b/src/main.c index b875a91..5e2085b 100644 --- a/src/main.c +++ b/src/main.c @@ -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]) { diff --git a/src/main.h b/src/main.h index 5aebf64..ac11121 100644 --- a/src/main.h +++ b/src/main.h @@ -104,7 +104,7 @@ typedef struct { typedef struct { Mode mode; gchar modkey; - int count; + guint count; } State; /* behaviour */ -- 2.20.1