From 48ded2300d81da56425a2ab18626949da4f77841 Mon Sep 17 00:00:00 2001
From: Daniel Carl <danielcarl@gmx.de>
Date: Fri, 15 Aug 2014 23:24:12 +0200
Subject: [PATCH] Added CTRL-0 to run normal mode command during input mode.

---
 doc/vimb.1  |  3 +++
 src/input.c | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/doc/vimb.1 b/doc/vimb.1
index ae58bb7..208d1dd 100644
--- a/doc/vimb.1
+++ b/doc/vimb.1
@@ -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
diff --git a/src/input.c b/src/input.c
index b34b423..5da62e8 100644
--- a/src/input.c
+++ b/src/input.c
@@ -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;
 }
-- 
2.20.1