Allow to configure the timeoutlen.
authorDaniel Carl <danielcarl@gmx.de>
Sat, 28 Sep 2013 15:24:28 +0000 (17:24 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 28 Sep 2013 15:24:28 +0000 (17:24 +0200)
Timeoutlen is  the time in milliseconds that is waited for a key code or
mapped key sequence to complete.

src/default.h
src/main.h
src/map.c
src/setting.c

index c0c029d..51d9305 100644 (file)
@@ -65,6 +65,7 @@ static char *default_config[] = {
     "set insecure-content-show=off",
     "set insecure-content-run=off",
 #endif
+    "set timeoutlen=1000",
     "cmap <Up> <C-P>",
     "cmap <Down> <C-N>",
     NULL
index 3488252..aa53829 100644 (file)
@@ -281,6 +281,7 @@ typedef struct {
     char   *download_dir;
     guint  history_max;
     char   *editor_command;
+    guint  timeoutlen;      /* timeout for ambiguous mappings */
 } Config;
 
 typedef struct {
index 07dcc3d..ee13214 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -167,7 +167,7 @@ MapState map_handle_keys(const char *keys, int keylen)
         if (map.timout_id) {
             g_source_remove(map.timout_id);
         }
-        map.timout_id = g_timeout_add(1000, (GSourceFunc)map_timeout, NULL);
+        map.timout_id = g_timeout_add(vb.config.timeoutlen, (GSourceFunc)map_timeout, NULL);
     }
 
     /* copy the keys onto the end of queue */
index cfe8d63..fab9d19 100644 (file)
@@ -44,6 +44,7 @@ static gboolean proxy(const Setting *s, const SettingType type);
 static gboolean user_style(const Setting *s, const SettingType type);
 static gboolean history_max_items(const Setting *s, const SettingType type);
 static gboolean editor_command(const Setting *s, const SettingType type);
+static gboolean timeoutlen(const Setting *s, const SettingType type);
 
 static Setting default_settings[] = {
     /* webkit settings */
@@ -89,6 +90,7 @@ static Setting default_settings[] = {
     {NULL, "status-sslinvalid-color-bg", TYPE_COLOR, status_color_bg, {0}},
     {NULL, "status-sslinvalid-color-fg", TYPE_COLOR, status_color_fg, {0}},
     {NULL, "status-sslinvalid-font", TYPE_FONT, status_font, {0}},
+    {NULL, "timeoutlen", TYPE_INTEGER, timeoutlen, {0}},
     {NULL, "input-bg-normal", TYPE_COLOR, input_style, {0}},
     {NULL, "input-bg-error", TYPE_COLOR, input_style, {0}},
     {NULL, "input-fg-normal", TYPE_COLOR, input_style, {0}},
@@ -700,3 +702,14 @@ static gboolean editor_command(const Setting *s, const SettingType type)
 
     return true;
 }
+
+static gboolean timeoutlen(const Setting *s, const SettingType type)
+{
+    if (type == SETTING_GET) {
+        print_value(s, &vb.config.timeoutlen);
+    } else {
+        vb.config.timeoutlen = abs(s->arg.i);
+    }
+
+    return true;
+}