From: Daniel Carl Date: Fri, 14 Jun 2013 07:26:45 +0000 (+0200) Subject: Removed vb_set_mode from the commands. X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=97a0fac8fba6fbb958ef3fe20a583f1913b4d1f9;p=vimb.git Removed vb_set_mode from the commands. This mode switching is only used if the commands are called from inputbox most of the time and not if called via keybindings. So we can skip the function calls for keybinds and do it in command_run_string instead. --- diff --git a/src/command.c b/src/command.c index 03c054c..714aa02 100644 --- a/src/command.c +++ b/src/command.c @@ -232,13 +232,15 @@ gboolean command_run_string(const char *input) gboolean success; Command command = NULL; Arg arg = {0}; + + vb_set_mode(VB_MODE_NORMAL | (vb.state.mode & VB_MODE_SEARCH), false); if (!command_parse_from_string(input, &command, &arg, &vb.state.count)) { return false; } success = command(&arg); g_free(arg.s); - + return success; } @@ -322,8 +324,6 @@ gboolean command_close(const Arg *arg) gboolean command_view_source(const Arg *arg) { - vb_set_mode(VB_MODE_NORMAL, false); - gboolean mode = webkit_web_view_get_view_source_mode(vb.gui.webview); webkit_web_view_set_view_source_mode(vb.gui.webview, !mode); webkit_web_view_reload(vb.gui.webview); @@ -334,7 +334,6 @@ gboolean command_view_source(const Arg *arg) gboolean command_navigate(const Arg *arg) { int count = vb.state.count ? vb.state.count : 1; - vb_set_mode(VB_MODE_NORMAL, false); WebKitWebView *view = vb.gui.webview; if (arg->i <= VB_NAVIG_FORWARD) { @@ -359,9 +358,6 @@ gboolean command_scroll(const Arg *arg) int direction = (arg->i & (1 << 2)) ? 1 : -1; GtkAdjustment *adjust = (arg->i & VB_SCROLL_AXIS_H) ? vb.gui.adjust_h : vb.gui.adjust_v; - /* keep possible search mode */ - vb_set_mode(VB_MODE_NORMAL | (vb.state.mode & VB_MODE_SEARCH), false); - max = gtk_adjustment_get_upper(adjust) - gtk_adjustment_get_page_size(adjust); /* type scroll */ if (arg->i & VB_SCROLL_TYPE_SCROLL) { @@ -393,8 +389,6 @@ gboolean command_map(const Arg *arg) { char *key; - vb_set_mode(VB_MODE_NORMAL, false); - if (!arg->s) { return false; } @@ -407,8 +401,6 @@ gboolean command_map(const Arg *arg) gboolean command_unmap(const Arg *arg) { - vb_set_mode(VB_MODE_NORMAL, false); - return keybind_remove_from_string(arg->s, arg->i); } @@ -417,7 +409,6 @@ gboolean command_set(const Arg *arg) gboolean success; char *param = NULL, *line = NULL; - vb_set_mode(VB_MODE_NORMAL, false); if (!arg->s || *(arg->s) == '\0') { return false; } @@ -443,8 +434,6 @@ gboolean command_inspect(const Arg *arg) gboolean enabled; WebKitWebSettings *settings = NULL; - vb_set_mode(VB_MODE_NORMAL, false); - settings = webkit_web_view_get_settings(vb.gui.webview); g_object_get(G_OBJECT(settings), "enable-developer-extras", &enabled, NULL); if (enabled) { @@ -472,8 +461,6 @@ gboolean command_hints(const Arg *arg) gboolean command_yank(const Arg *arg) { - vb_set_mode(VB_MODE_NORMAL, true); - if (arg->i & COMMAND_YANK_SELECTION) { char *text = NULL; /* copy current selection to clipboard */ @@ -568,8 +555,6 @@ gboolean command_shortcut(const Arg *arg) { gboolean result; - vb_set_mode(VB_MODE_NORMAL, false); - if (arg->i) { char *handle; @@ -590,8 +575,6 @@ gboolean command_shortcut(const Arg *arg) gboolean command_shortcut_default(const Arg *arg) { - vb_set_mode(VB_MODE_NORMAL, false); - return shortcut_set_default(arg->s); } @@ -600,8 +583,6 @@ gboolean command_zoom(const Arg *arg) float step, level; int count = vb.state.count ? vb.state.count : 1; - vb_set_mode(VB_MODE_NORMAL, false); - if (arg->i & COMMAND_ZOOM_RESET) { webkit_web_view_set_zoom_level(vb.gui.webview, 1.0); @@ -642,8 +623,6 @@ gboolean command_history(const Arg *arg) gboolean command_bookmark(const Arg *arg) { - vb_set_mode(VB_MODE_NORMAL, false); - bookmark_add(GET_URI(), arg->s); return true; } @@ -653,8 +632,6 @@ gboolean command_eval(const Arg *arg) gboolean success; char *value = NULL; - vb_set_mode(VB_MODE_NORMAL, false); - success = vb_eval_script( webkit_web_view_get_main_frame(vb.gui.webview), arg->s, NULL, &value ); @@ -687,8 +664,6 @@ gboolean command_descent(const Arg *arg) const char *uri, *p = NULL, *domain = NULL; uri = GET_URI(); - - vb_set_mode(VB_MODE_NORMAL, false); if (!uri || *uri == '\0') { return false; } @@ -737,7 +712,6 @@ gboolean command_save(const Arg *arg) WebKitDownload *download; const char *uri, *path = NULL; - vb_set_mode(VB_MODE_NORMAL, false); if (arg->i == COMMAND_SAVE_CURRENT) { uri = GET_URI(); /* given string is the path to save the download to */ @@ -763,7 +737,6 @@ gboolean command_shellcmd(const Arg *arg) int status, argc; char *cmd, *exp, *error = NULL, *out = NULL, **argv; - vb_set_mode(VB_MODE_NORMAL, false); if (!arg->s || *(arg->s) == '\0') { return false; }