gboolean command_mode(const Arg *arg)
{
- return vb_set_mode(arg->i, false);
+ /* if a main mode is given - set the mode like it is */
+ if (CLEAN_MODE(arg->i)) {
+ return vb_set_mode(arg->i, false);
+ }
+
+ /* else combine the current main mode with the new submode */
+ /* TODO move this logic to main.c: vb_set_mode() */
+ return vb_set_mode(arg->i|CLEAN_MODE(vb.state.mode), false);
}
gboolean command_focusinput(const Arg *arg)
"cmap <up>=hist-prev",
"cmap <down>=hist-next",
"imap <ctrl-t>=editor",
+ "imap <ctrl-z>=pass-through",
"shortcut-add dl=https://duckduckgo.com/html/?q=$0",
"shortcut-add dd=https://duckduckgo.com/?q=$0",
"shortcut-default dl",
/* skip further logic if we are in pass through mode */
if (vb.state.mode & VB_MODE_PASSTHROUGH) {
- return true;
+ return false;
}
/* allow mode keys and counts only in normal mode and search mode */
return result;
}
-/**
- * Set the base modes. All other mode flags like completion can be set directly
- * to vb.state.mode.
- */
gboolean vb_set_mode(Mode mode, gboolean clean)
{
/* process only if mode has changed */
command_search(&((Arg){VB_SEARCH_OFF}));
} else if ((vb.state.mode & VB_MODE_HINTING) && !(mode & VB_MODE_HINTING)) {
hints_clear();
- } else if (CLEAN_MODE(vb.state.mode) == VB_MODE_INSERT) {
+ } else if (CLEAN_MODE(vb.state.mode) == VB_MODE_INSERT && !(mode & VB_MODE_INSERT)) {
clean = true;
dom_clear_focus(vb.gui.webview);
}
case VB_MODE_NORMAL:
history_rewind();
gtk_widget_grab_focus(GTK_WIDGET(vb.gui.webview));
+ if (mode & VB_MODE_PASSTHROUGH) {
+ clean = false;
+ vb_echo(VB_MSG_NORMAL, false, "-- PASS THROUGH --");
+ }
break;
case VB_MODE_COMMAND:
case VB_MODE_INSERT:
clean = false;
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 --");
+ if (mode & VB_MODE_PASSTHROUGH) {
+ vb_echo(VB_MSG_NORMAL, false, "-- PASS THROUGH --");
+ } else {
+ vb_echo(VB_MSG_NORMAL, false, "-- INPUT --");
+ }
break;
}
vb.state.mode = mode;
gtk_editable_set_position(GTK_EDITABLE(vb.gui.inputbox), -1); \
}
#define GET_URI() (webkit_web_view_get_uri(vb.gui.webview))
-#define CLEAN_MODE(mode) ((mode) & ~(VB_MODE_COMPLETE | VB_MODE_SEARCH | VB_MODE_HINTING))
+#define CLEAN_MODE(mode) ((mode) & (VB_MODE_NORMAL|VB_MODE_COMMAND|VB_MODE_INSERT))
#define CLEAR_INPUT() (vb_echo(VB_MSG_NORMAL, ""))
#define PRIMARY_CLIPBOARD() gtk_clipboard_get(GDK_SELECTION_PRIMARY)
#define SECONDARY_CLIPBOARD() gtk_clipboard_get(GDK_NONE)
VB_MODE_NORMAL = 1<<0,
VB_MODE_COMMAND = 1<<1,
VB_MODE_INSERT = 1<<2,
- VB_MODE_PASSTHROUGH = 1<<3,
/* sub modes */
+ VB_MODE_PASSTHROUGH = 1<<3, /* normal or insert mode */
VB_MODE_SEARCH = 1<<4, /* normal mode */
VB_MODE_COMPLETE = 1<<5, /* command mode */
VB_MODE_HINTING = 1<<6, /* command mode */