Added CTRL-0 to run normal mode command during input mode.
authorDaniel Carl <danielcarl@gmx.de>
Fri, 15 Aug 2014 21:24:12 +0000 (23:24 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Fri, 15 Aug 2014 21:24:12 +0000 (23:24 +0200)
doc/vimb.1
src/input.c

index ae58bb7..208d1dd 100644 (file)
@@ -635,6 +635,9 @@ number of copies, orientation, etc.
 .B <Esc>, CTRL\-[
 Switch back to normal mode.
 .TP
+.B CTRL\-O
+Executes the next command as normal mode command and return to input mode.
+.TP
 .B CTRL\-T
 Open configured editor with content of current form field.
 .TP
index b34b423..5da62e8 100644 (file)
@@ -25,6 +25,7 @@
 #include "dom.h"
 #include "util.h"
 #include "ascii.h"
+#include "normal.h"
 
 typedef struct {
     char    *file;
@@ -59,11 +60,31 @@ void input_leave(void)
  */
 VbResult input_keypress(int key)
 {
+    static gboolean ctrlo = false;
+
+    if (ctrlo) {
+        /* if we are in ctrl-O mode perform the next keys as normal mode
+         * commands until the command is complete or error */
+        VbResult res = normal_keypress(key);
+        if (res != RESULT_MORE) {
+            ctrlo = false;
+            vb_echo(VB_MSG_NORMAL, false, "-- INPUT --");
+        }
+        return res;
+    }
+
     switch (key) {
         case CTRL('['): /* esc */
             mode_enter('n');
             return RESULT_COMPLETE;
 
+        case CTRL('O'):
+            /* enter CTRL-0 mode to execute next command in normal mode */
+            ctrlo           = true;
+            vb.mode->flags |= FLAG_NOMAP;
+            vb_echo(VB_MSG_NORMAL, false, "-- (input) --");
+            return RESULT_MORE;
+
         case CTRL('T'):
             return input_open_editor();
 
@@ -71,6 +92,7 @@ VbResult input_keypress(int key)
             mode_enter('p');
             return RESULT_COMPLETE;
     }
+
     vb.state.processed_key = false;
     return RESULT_ERROR;
 }