From: Daniel Carl Date: Sat, 23 Mar 2013 22:24:24 +0000 (+0100) Subject: Fixed wrong mode if no hints where found. X-Git-Url: https://git.owens.tech/wrapped.html/wrapped.html/git?a=commitdiff_plain;h=e8054292c7aa6003e42ed35c88dabbd6bb079d31;p=vimb.git Fixed wrong mode if no hints where found. If hinting was started, but no hint was found, the input box was still activated. Now we set the hint mode immediately in the hints_create function. In the previous implementation the hinting mode was set in the command function that didn't know if a hint where found or not and switched to hinting mode also if no hint mas found. --- diff --git a/src/command.c b/src/command.c index 285b023..a77d2bb 100644 --- a/src/command.c +++ b/src/command.c @@ -360,10 +360,9 @@ gboolean command_inspect(const Arg* arg) gboolean command_hints(const Arg* arg) { command_write_input(arg->s); + /* mode will be set in hints_create - so we don't neet to do it here */ hints_create(NULL, arg->i, (arg->s ? strlen(arg->s) : 0)); - vb_set_mode(VB_MODE_HINTING, FALSE); - return TRUE; } @@ -371,8 +370,6 @@ gboolean command_hints_focus(const Arg* arg) { hints_focus_next(arg->i ? TRUE : FALSE); - vb_set_mode(VB_MODE_HINTING, FALSE); - return TRUE; } diff --git a/src/hints.c b/src/hints.c index 5bdaed0..7118c31 100644 --- a/src/hints.c +++ b/src/hints.c @@ -61,6 +61,8 @@ void hints_create(const char* input, guint mode, const guint prefixLength) { char* js = NULL; if (CLEAN_MODE(vb.state.mode) != VB_MODE_HINTING) { + vb_set_mode(VB_MODE_HINTING, FALSE); + Style* style = &vb.style; vb.hints.prefixLength = prefixLength; vb.hints.mode = mode; @@ -85,10 +87,11 @@ void hints_create(const char* input, guint mode, const guint prefixLength) style->hint_style, MAXIMUM_HINTS ); - hints_run_script(js); - g_free(js); hints_observe_input(TRUE); + + hints_run_script(js); + g_free(js); } @@ -133,13 +136,10 @@ static void hints_run_script(char* js) vb.gui.webview, "hovering-over-link", NULL, *(value + 5) == '\0' ? NULL : (value + 5) ); } else if (!strncmp(value, "DONE:", 5)) { - hints_observe_input(FALSE); vb_set_mode(VB_MODE_NORMAL, TRUE); } else if (!strncmp(value, "INSERT:", 7)) { - hints_observe_input(FALSE); vb_set_mode(VB_MODE_INSERT, FALSE); } else if (!strncmp(value, "DATA:", 5)) { - hints_observe_input(FALSE); Arg a = {0}; char* v = (value + 5); if (mode & HINTS_PROCESS_INPUT) { @@ -157,7 +157,6 @@ static void hints_run_script(char* js) static void hints_fire() { - hints_observe_input(FALSE); char* js = g_strdup_printf("%s.fire();", HINT_VAR); hints_run_script(js); g_free(js); @@ -177,9 +176,6 @@ static void hints_observe_input(gboolean observe) g_signal_handler_disconnect(G_OBJECT(vb.gui.inputbox), vb.hints.keypress_handler); vb.hints.change_handler = vb.hints.keypress_handler = 0; - - /* clear the input box */ - vb_echo_force(VB_MSG_NORMAL, FALSE, ""); } } diff --git a/src/main.c b/src/main.c index 87d4972..f76dd71 100644 --- a/src/main.c +++ b/src/main.c @@ -216,20 +216,20 @@ gboolean vb_set_mode(Mode mode, gboolean clean) ) { completion_clean(); } - int clean_mode = CLEAN_MODE(vb.state.mode); + int current_mode = CLEAN_MODE(vb.state.mode); switch (CLEAN_MODE(mode)) { case VB_MODE_NORMAL: /* do this only if the mode is really switched */ - if (clean_mode != VB_MODE_NORMAL) { + if (current_mode != VB_MODE_NORMAL) { history_rewind(); } - if (clean_mode == VB_MODE_HINTING) { + if (current_mode == VB_MODE_HINTING) { /* if previous mode was hinting clear the hints */ hints_clear(); - } else if (clean_mode == VB_MODE_INSERT) { + } else if (current_mode == VB_MODE_INSERT) { /* clean the input if current mode is insert to remove -- INPUT -- */ clean = TRUE; - } else if (clean_mode == VB_MODE_SEARCH) { + } else if (current_mode == VB_MODE_SEARCH) { /* cleaup previous search */ command_search(&((Arg){VB_SEARCH_OFF})); }