adds incsearch setting
authorRobert Timm <mail@rtti.de>
Sat, 8 Apr 2017 20:40:29 +0000 (22:40 +0200)
committerRobert Timm <mail@rtti.de>
Sat, 8 Apr 2017 20:40:29 +0000 (22:40 +0200)
src/ex.c
src/main.h
src/setting.c

index cc4bdbe..46f02a7 100644 (file)
--- a/src/ex.c
+++ b/src/ex.c
@@ -348,6 +348,15 @@ VbResult ex_keypress(Client *c, int key)
         }
     }
 
+    if (c->config.incsearch && key != KEY_CR) {
+        gtk_text_buffer_get_bounds(buffer, &start, &end);
+        text = gtk_text_buffer_get_text(buffer, &start, &end, false);
+        if (text && (*text == '/' || *text == '?')) {
+            command_search(c, &((Arg){0, NULL})); /* stop last search */
+            command_search(c, &((Arg){*text == '/' ? 1 : -1, (char*)text + 1}));
+        }
+    }
+
     /* 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) {
@@ -493,7 +502,11 @@ static void input_activate(Client *c)
         case '/': count = 1; /* fall through */
         case '?':
             vb_enter(c, 'n');
-            command_search(c, &((Arg){count, cmd}));
+
+            /* start search, if incsearch, it's done while typing */
+            if (!c->config.incsearch) {
+                command_search(c, &((Arg){count, cmd}));
+            }
             break;
 
         case ';': /* fall through */
index 59e1fbb..9d016a5 100644 (file)
@@ -226,6 +226,7 @@ struct Client {
         GHashTable              *settings;
         guint                   scrollstep;
         gboolean                input_autohide;
+        gboolean                incsearch;
         /* completion */
         GdkRGBA                 comp_fg[COMP_LAST];
         GdkRGBA                 comp_bg[COMP_LAST];
index 59bf50a..9c5741f 100644 (file)
@@ -140,6 +140,7 @@ void setting_init(Client *c)
     i = 100;
     setting_add(c, "default-zoom", TYPE_INTEGER, &i, default_zoom, 0, NULL);
     setting_add(c, "download-path", TYPE_CHAR, &"~", NULL, 0, NULL);
+    setting_add(c, "incsearch", TYPE_BOOLEAN, &off, internal, 0, &c->config.incsearch);
 
 #ifdef FEATURE_GUI_STYLE_VIMB2_COMPAT
     /* gui style settings vimb2 compatibility */