Fixed leaving input mode on load commit (#33).
authorDaniel Carl <danielcarl@gmx.de>
Wed, 12 Jun 2013 22:13:43 +0000 (00:13 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Thu, 13 Jun 2013 07:58:54 +0000 (09:58 +0200)
If a page was loaded and text was typed into the inputbox, the input
mode was left on WEBKIT_LOAD_COMMITED. Now we keep in insert mode also if
the page loads to allow to type in a command into inputbox.

Moved modkey unset to keybind.c where the modkeys are set.

src/keybind.c
src/main.c

index 515cb7c..b98e6d7 100644 (file)
@@ -245,6 +245,7 @@ static gboolean keypress_cb(WebKitWebView *webview, GdkEventKey *event)
 
     /* check for escape or modkeys or counts */
     if (IS_ESCAPE_KEY(keyval, state)) {
+        vb.state.modkey = vb.state.count = 0;
         /* switch to normal mode and clear the input box */
         vb_set_mode(VB_MODE_NORMAL, true);
 
@@ -275,6 +276,9 @@ static gboolean keypress_cb(WebKitWebView *webview, GdkEventKey *event)
         Keybind *keybind = (Keybind*)link->data;
         command_run(keybind->command, keybind->param);
 
+        vb.state.modkey = vb.state.count = 0;
+        vb_update_statusbar();
+
         return true;
     }
 
index 4fc3921..fc84477 100644 (file)
@@ -149,9 +149,6 @@ gboolean vb_load_uri(const Arg *arg)
         uri = g_strdup_printf("http://%s", path);
     }
 
-    /* change state to normal mode */
-    vb_set_mode(VB_MODE_NORMAL, false);
-
     if (arg->i == VB_TARGET_NEW) {
         guint i = 0;
         char *cmd[7], xid[64];
@@ -205,8 +202,6 @@ gboolean vb_set_clipboard(const Arg *arg)
  */
 gboolean vb_set_mode(Mode mode, gboolean clean)
 {
-    vb.state.modkey = vb.state.count  = 0;
-
     /* process only if mode has changed */
     if (vb.state.mode != mode) {
         /* leaf the old mode */
@@ -421,8 +416,12 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec)
                 run_user_script(frame);
             }
 
-            /* status bar is updated by vb_set_mode */
-            vb_set_mode(VB_MODE_NORMAL , false);
+            if (vb.state.mode & VB_MODE_INSERT) {
+                /* status bar is updated by vb_set_mode */
+                vb_set_mode(VB_MODE_NORMAL, false);
+            } else {
+                vb_update_statusbar();
+            }
             vb_update_urlbar(uri);
 
             break;