From: Daniel Carl Date: Mon, 2 Jun 2014 14:54:48 +0000 (+0200) Subject: Switch back to normal mode if inputbox is cleared (#55). X-Git-Url: https://git.owens.tech/about.html/about.html/git?a=commitdiff_plain;h=3bd6f28bdc9fa5471bf3a33c5dbc3fc8583c348b;p=vimb.git Switch back to normal mode if inputbox is cleared (#55). --- diff --git a/src/ex.c b/src/ex.c index 243c069..e75a2e8 100644 --- a/src/ex.c +++ b/src/ex.c @@ -224,6 +224,7 @@ void ex_leave(void) VbResult ex_keypress(int key) { GtkTextIter start, end; + gboolean check_empty = false; GtkTextBuffer *buffer = vb.gui.buffer; GtkTextMark *mark; VbResult res; @@ -281,6 +282,7 @@ VbResult ex_keypress(int key) mark = gtk_text_buffer_get_insert(buffer); gtk_text_buffer_get_iter_at_mark(buffer, &start, mark); gtk_text_buffer_backspace(buffer, &start, true, true); + check_empty = true; break; case CTRL('W'): @@ -295,6 +297,7 @@ VbResult ex_keypress(int key) if (gtk_text_iter_backward_word_start(&start)) { gtk_text_buffer_delete(buffer, &start, &end); } + check_empty = true; break; case CTRL('B'): @@ -335,6 +338,16 @@ VbResult ex_keypress(int key) } } + /* if the user deleted some content of the inputbox we check if the + * inputbox is empty - if so we switch back to normal like vim does */ + if (check_empty) { + gtk_text_buffer_get_bounds(buffer, &start, &end); + if (gtk_text_iter_equal(&start, &end)) { + mode_enter('n'); + vb_set_input_text(""); + } + } + if (res == RESULT_COMPLETE) { info.cutbuf = 0; info.phase = PHASE_START;