Added command pass-through to switch to pass through mode.
authorDaniel Carl <danielcarl@gmx.de>
Mon, 5 Aug 2013 19:10:30 +0000 (21:10 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Mon, 5 Aug 2013 19:55:58 +0000 (21:55 +0200)
The pass-through mode allows to skip all keybindings accept of <esc> and
<ctrl-c> in vimb to let the webview handle them.

doc/vimb.1
src/command.c
src/command.h
src/default.h
src/keybind.c
src/main.c
src/main.h

index c6b2041..9e0cdfd 100644 (file)
@@ -48,6 +48,12 @@ Used for editing text elements in a webpage.
 .TP
 .B Command Mode
 Execute PROJECT commands from the builtin inputbox (commandline).
+.TP
+.B Pass-Through Mode
+In Pass-Through mode only the <ctrl-c> and <esc> keybindings are interpreted
+by PROJECT, all other keystrokes are given to the webview to handle them. This
+allows to use websites that uses keybindings itself, that might be swallowed
+by PROJECT else.
 
 .SH COMMANDS
 Commands are a central part in PROJECT. They are used for nearly all things
@@ -369,6 +375,11 @@ Format:
 
 Example:
 ":run set input-bg-normal=#ff0 | set input-fg-normal=#f0f | 5pagedown"
+
+.TP
+.B pass-through
+Switch PROJECT into pass-trough mode.
+
 .TP
 .BI "shellcmd " CMD
 Runs given shell \fICMD\fP syncron and print the output into inputbox. The
@@ -636,6 +647,9 @@ Search for \fIN\fPnth next search result.
 .TP
 .BI [ N ]N
 Search for \fIN\fPnth previous search result.
+.TP
+.B ctrl-z
+Switch PROJECT into pass-through mode.
 
 .SS COMMAND_MODE
 .TP
index 62b8cb1..0f64951 100644 (file)
@@ -131,6 +131,7 @@ static CommandInfo cmd_list[] = {
     {"queue-pop",                 NULL,    command_queue,                {COMMAND_QUEUE_POP}},
     {"queue-clear",               NULL,    command_queue,                {COMMAND_QUEUE_CLEAR}},
 #endif
+    {"pass-through",              NULL,    command_mode,                 {VB_MODE_PASSTHROUGH}},
 };
 
 static void editor_resume(GPid pid, int status, OpenEditorData *data);
@@ -944,6 +945,11 @@ gboolean command_queue(const Arg *arg)
 }
 #endif
 
+gboolean command_mode(const Arg *arg)
+{
+    return vb_set_mode(arg->i, false);
+}
+
 gboolean command_editor(const Arg *arg)
 {
     char *file_path = NULL;
index 50e5ab0..3cdd36f 100644 (file)
@@ -93,5 +93,6 @@ gboolean command_shellcmd(const Arg *arg);
 #ifdef FEATURE_QUEUE
 gboolean command_queue(const Arg *arg);
 #endif
+gboolean command_mode(const Arg *arg);
 
 #endif /* end of include guard: _COMMAND_H */
index 7dfb4be..929c222 100644 (file)
@@ -83,6 +83,7 @@ static char *default_config[] = {
     "nmap zz=zoomreset",
     "nmap gu=descent",
     "nmap gU=descent!",
+    "nmap <ctrl-z>=pass-through",
     "cmap <tab>=next",
     "cmap <shift-tab>=prev",
     "cmap <up>=hist-prev",
index 00c7879..59ea62e 100644 (file)
@@ -255,6 +255,11 @@ static gboolean keypress_cb(WebKitWebView *webview, GdkEventKey *event)
         return true;
     }
 
+    /* skip further logic if we are in pass through mode */
+    if (vb.state.mode & VB_MODE_PASSTHROUGH) {
+        return true;
+    }
+
     /* allow mode keys and counts only in normal mode and search mode */
     if (vb.state.mode & (VB_MODE_NORMAL|VB_MODE_SEARCH)) {
         if (vb.state.modkey == 0 && ((keyval >= GDK_1 && keyval <= GDK_9)
index 5b9739f..5732823 100644 (file)
@@ -232,6 +232,12 @@ gboolean vb_set_mode(Mode mode, gboolean clean)
                 gtk_widget_grab_focus(GTK_WIDGET(vb.gui.webview));
                 vb_echo(VB_MSG_NORMAL, false, "-- INPUT --");
                 break;
+
+            case VB_MODE_PASSTHROUGH:
+                clean = false;
+                gtk_widget_grab_focus(GTK_WIDGET(vb.gui.webview));
+                vb_echo(VB_MSG_NORMAL, false, "-- PASS THROUGH --");
+                break;
         }
         vb.state.mode = mode;
     }
index 6e6854d..6618191 100644 (file)
@@ -116,10 +116,11 @@ typedef enum _vb_mode {
     VB_MODE_NORMAL        = 1<<0,
     VB_MODE_COMMAND       = 1<<1,
     VB_MODE_INSERT        = 1<<2,
+    VB_MODE_PASSTHROUGH   = 1<<3,
     /* sub modes */
-    VB_MODE_SEARCH        = 1<<3, /* normal mode */
-    VB_MODE_COMPLETE      = 1<<4, /* command mode */
-    VB_MODE_HINTING       = 1<<5, /* command mode */
+    VB_MODE_SEARCH        = 1<<4, /* normal mode */
+    VB_MODE_COMPLETE      = 1<<5, /* command mode */
+    VB_MODE_HINTING       = 1<<6, /* command mode */
 } Mode;
 
 typedef enum {