]> Sergey Matveev's repositories - nnn.git/commitdiff
Use / to toggle string and regex
authorArun Prakash Jana <engineerarun@gmail.com>
Wed, 15 Jan 2020 04:35:19 +0000 (10:05 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Wed, 15 Jan 2020 04:35:19 +0000 (10:05 +0530)
nnn.1
src/nnn.c
src/nnn.h

diff --git a/nnn.1 b/nnn.1
index 185c1463f463279398bf139cc431813a10c610ba..28de0612168bd37a3d41da883366141f64eb01e0 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -142,9 +142,7 @@ Filters are strings to find matching entries in the current directory instantly
 .Pp
 To modify match criteria at runtime:
 .br
-- string to regex: press '\\' at empty filter prompt
-.br
-- regex to string: press '/' at empty filter prompt
+- toggle between string and regex: press '/' at empty filter prompt
 .br
 - toggle case sensitivity: press ':' at empty filter prompt
 .Pp
index 711b0d0e0bcd356f555b37c4353f7974af12509f..cf1e2953a42dd459e9d075131cb1ab88d060358c 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2072,7 +2072,7 @@ static void showfilterinfo(void)
 
        i = getorderstr(info);
 
-       snprintf(info + i, REGEX_MAX - i - 1, "  %s [keys /\\], %s [key :]",
+       snprintf(info + i, REGEX_MAX - i - 1, "  %s [/], %s [:]",
                 (cfg.regex ? "regex" : "str"),
                 ((fnstrstr == &strcasestr) ? "ic" : "noic"));
        printinfoln(info);
@@ -2238,20 +2238,11 @@ static int filterentries(char *path, char *lastname)
                                        continue;
                                }
 
-                               /* string to regex */
-                               if (*ch == RFILTER && ln[0] == FILTER) {
-                                       wln[0] = ln[0] = RFILTER;
-                                       cfg.regex = TRUE;
-                                       filterfn = &visible_re;
-                                       showfilter(ln);
-                                       continue;
-                               }
-
-                               /* regex to string */
-                               if (*ch == FILTER && ln[0] == RFILTER) {
-                                       wln[0] = ln[0] = FILTER;
-                                       cfg.regex = FALSE;
-                                       filterfn = &visible_str;
+                               /* toggle string or regex filter */
+                               if (*ch == FILTER) {
+                                       wln[0] = ln[0] = (ln[0] == FILTER) ? RFILTER : FILTER;
+                                       cfg.regex ^= 1;
+                                       filterfn = (filterfn == &visible_str) ? &visible_re : &visible_str;
                                        showfilter(ln);
                                        continue;
                                }
@@ -4994,7 +4985,7 @@ nochange:
                case SEL_MFLTR: // fallthrough
                case SEL_TOGGLEDOT: // fallthrough
                case SEL_DETAIL: // fallthrough
-               case SEL_ORDER:
+               case SEL_SORT:
                        switch (sel) {
                        case SEL_MFLTR:
                                cfg.filtermode ^= 1;
@@ -5020,7 +5011,7 @@ nochange:
                                cfg.showdetail ? (printptr = &printent_long) : (printptr = &printent);
                                cfg.blkorder = 0;
                                continue;
-                       default: /* SEL_ORDER */
+                       default: /* SEL_SORT */
                                r = get_input(messages[MSG_ORDER]);
 
                                if ((r == 'a' || r == 'd' || r == 'e' || r == 's' || r == 't')
index d65febf204933fff017a1452b639fbd669d25a88..adebd69acd40b0398e8311740acf83444173f561 100644 (file)
--- a/src/nnn.h
+++ b/src/nnn.h
@@ -67,7 +67,7 @@ enum action {
        SEL_STATS,
        SEL_CHMODX,
        SEL_ARCHIVE,
-       SEL_ORDER,
+       SEL_SORT,
        SEL_REDRAW,
        SEL_SEL,
        SEL_SELMUL,
@@ -174,8 +174,8 @@ static struct key bindings[] = {
        /* Create archive */
        { 'z',            SEL_ARCHIVE },
        /* Sort toggles */
-       { 't',            SEL_ORDER },
-       { CONTROL('T'),   SEL_ORDER },
+       { 't',            SEL_SORT },
+       { CONTROL('T'),   SEL_SORT },
        /* Redraw window */
        { CONTROL('L'),   SEL_REDRAW },
        /* Select current file path */