diff options
author | Daniel Carl <danielcarl@gmx.de> | 2013-08-05 21:10:30 +0200 |
---|---|---|
committer | Daniel Carl <danielcarl@gmx.de> | 2013-08-05 21:55:58 +0200 |
commit | ce1fcd3d58f6406f457a5f9a6ce1858626e8f790 (patch) | |
tree | 1f48c29575ed3762a97f382bfccb3c9eaad70139 /src | |
parent | 861421b01770c485a971f3a403b1b9163fa5e2be (diff) |
Added command pass-through to switch to pass through mode.
The pass-through mode allows to skip all keybindings accept of <esc> and
<ctrl-c> in vimb to let the webview handle them.
Diffstat (limited to 'src')
-rw-r--r-- | src/command.c | 6 | ||||
-rw-r--r-- | src/command.h | 1 | ||||
-rw-r--r-- | src/default.h | 1 | ||||
-rw-r--r-- | src/keybind.c | 5 | ||||
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/main.h | 7 |
6 files changed, 23 insertions, 3 deletions
diff --git a/src/command.c b/src/command.c index 62b8cb1..0f64951 100644 --- a/src/command.c +++ b/src/command.c @@ -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; diff --git a/src/command.h b/src/command.h index 50e5ab0..3cdd36f 100644 --- a/src/command.h +++ b/src/command.h @@ -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 */ diff --git a/src/default.h b/src/default.h index 7dfb4be..929c222 100644 --- a/src/default.h +++ b/src/default.h @@ -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", diff --git a/src/keybind.c b/src/keybind.c index 00c7879..59ea62e 100644 --- a/src/keybind.c +++ b/src/keybind.c @@ -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) @@ -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; } @@ -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 { |