]> Sergey Matveev's repositories - nnn.git/commitdiff
Remove filter as you type mode
authorsin <sin@2f30.org>
Mon, 8 Feb 2016 16:52:07 +0000 (16:52 +0000)
committersin <sin@2f30.org>
Mon, 8 Feb 2016 16:52:07 +0000 (16:52 +0000)
Nobody uses it and adds additional complexity.

config.def.h
noice.1
noice.c

index 4b1284688ce72acc94ec7b04e06e7656af6db29f..e1368dc0e184698f34edab7e12d8b5f61d10595c 100644 (file)
@@ -32,8 +32,6 @@ struct key bindings[] = {
        /* Filter */
        { '/',            SEL_FLTR },
        { '&',            SEL_FLTR },
-       /* Filter as you type */
-       { '?',            SEL_TYPE },
        /* Next */
        { 'j',            SEL_NEXT },
        { KEY_DOWN,       SEL_NEXT },
diff --git a/noice.1 b/noice.1
index e4cba0c2fc3b65525cf163359c5a339255331e13..c23cb9aa8495dcdd52919f64d77d3cc1f4fbd0cc 100644 (file)
--- a/noice.1
+++ b/noice.1
@@ -47,8 +47,6 @@ Open file or enter directory.
 Back up one directory level.
 .It Ic / or &
 Change filter (see below for more information).
-.It Ic \&?
-Enter filter-as-you-type mode.
 .It Ic c
 Change into the given directory.
 .It Ic t
diff --git a/noice.c b/noice.c
index d1b3b82f6592ac5f849b0bbb10943baa3defbee3..2b000adfc14bdde35fe17db91582e09a3d6bb4e7 100644 (file)
--- a/noice.c
+++ b/noice.c
@@ -50,7 +50,6 @@ enum action {
        SEL_BACK,
        SEL_GOIN,
        SEL_FLTR,
-       SEL_TYPE,
        SEL_NEXT,
        SEL_PREV,
        SEL_PGDN,
@@ -355,58 +354,6 @@ readln(void)
        return ln[0] ? strdup(ln) : NULL;
 }
 
-/*
- * Read one key and modify the provided string accordingly.
- * Returns 0 when more input is expected and 1 on completion.
- */
-int
-readmore(char **str)
-{
-       int c, ret = 0;
-       int i;
-       char *ln = *str;
-
-       timeout(-1);
-       if (ln != NULL)
-               i = strlen(ln);
-       else
-               i = 0;
-       DPRINTF_D(i);
-
-       curs_set(TRUE);
-
-       c = getch();
-       switch (c) {
-       case KEY_ENTER:
-       case '\r':
-               ret = 1;
-               break;
-       case KEY_BACKSPACE:
-       case CONTROL('H'):
-               i--;
-               if (i > 0) {
-                       ln = xrealloc(ln, (i + 1) * sizeof(*ln));
-                       ln[i] = '\0';
-               } else {
-                       free(ln);
-                       ln = NULL;
-               }
-               break;
-       default:
-               i++;
-               ln = xrealloc(ln, (i + 1) * sizeof(*ln));
-               ln[i - 1] = c;
-               ln[i] = '\0';
-       }
-
-       curs_set(FALSE);
-
-       *str = ln;
-       timeout(1000);
-
-       return ret;
-}
-
 int
 canopendir(char *path)
 {
@@ -627,25 +574,18 @@ browse(const char *ipath, const char *ifilter)
        struct stat sb;
        regex_t re;
        int r, fd;
-       int nowtyping = 0;
 
        strlcpy(path, ipath, sizeof(path));
        strlcpy(fltr, ifilter, sizeof(fltr));
 begin:
        r = populate();
        if (r == -1) {
-               if (!nowtyping) {
-                       printwarn();
-                       goto nochange;
-               }
+               printwarn();
+               goto nochange;
        }
 
        for (;;) {
                redraw();
-
-               /* Handle filter-as-you-type mode */
-               if (nowtyping)
-                       goto moretyping;
 nochange:
                switch (nextsel(&run, &env)) {
                case SEL_QUIT:
@@ -734,40 +674,6 @@ nochange:
                        if (n > 0)
                                mkpath(path, dents[cur].name, oldpath, sizeof(oldpath));
                        goto begin;
-               case SEL_TYPE:
-                       nowtyping = 1;
-                       tmp = NULL;
-moretyping:
-                       printprompt("type: ");
-                       if (tmp != NULL)
-                               printw("%s", tmp);
-                       r = readmore(&tmp);
-                       DPRINTF_D(r);
-                       DPRINTF_S(tmp);
-                       if (r == 1)
-                               nowtyping = 0;
-                       /* Check regex errors */
-                       if (tmp != NULL) {
-                               r = setfilter(&re, tmp);
-                               if (r != 0)
-                                       if (nowtyping) {
-                                               goto moretyping;
-                                       } else {
-                                               free(tmp);
-                                               goto nochange;
-                                       }
-                       }
-                       /* Copy or reset filter */
-                       if (tmp != NULL)
-                               strlcpy(fltr, tmp, sizeof(fltr));
-                       else
-                               strlcpy(fltr, ifilter, sizeof(fltr));
-                       /* Save current */
-                       if (n > 0)
-                               mkpath(path, dents[cur].name, oldpath, sizeof(oldpath));
-                       if (!nowtyping)
-                               free(tmp);
-                       goto begin;
                case SEL_NEXT:
                        if (cur < n - 1)
                                cur++;