]> Sergey Matveev's repositories - nnn.git/commitdiff
Alt+Esc to clear filter and exit filter prompt
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 29 May 2020 03:16:45 +0000 (08:46 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 29 May 2020 03:20:33 +0000 (08:50 +0530)
It's a little annoying that one has to press ^L followed by Esc to go back
to the normal view. We cannot reload the directory on Esc because that will
break the filter filtered view feature. So we take this route.

src/nnn.c

index 6058094891c003d0a8b205caf998cc72c9bf5ffb..4ffab55d27e1401c9ac8d7f5cef482109b2c8c40 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2588,8 +2588,17 @@ static int filterentries(char *path, char *lastname)
 #endif
                case 27: /* Exit filter mode on Escape and Alt+key */
                        if (handle_alt_key(ch) != ERR) {
-                               unget_wch(*ch);
-                               *ch = CONTROL('S');
+                               if (*ch == 27) { /* Handle Alt + Esc */
+                                       if (wln[1]) {
+                                               ln[REGEX_MAX - 1] = ln[1];
+                                               ln[1] = wln[1] = '\0';
+                                               ndents = total;
+                                               *ch = CONTROL('L');
+                                       }
+                               } else {
+                                       unget_wch(*ch);
+                                       *ch = CONTROL('S');
+                               }
                        }
                        goto end;
                }
@@ -4122,14 +4131,14 @@ static void show_help(const char *path)
               "9Lt h  Parent%-12c~ ` @ -  HOME, /, start, last\n"
           "5Ret Rt l  Open%-20c'  First file/match\n"
               "9g ^A  Top%-18c. F5  Toggle hidden\n"
-              "9G ^E  End%-21c0  Lock terminal\n"
+              "9G ^E  End%-21c+  Toggle auto-advance\n"
               "9b ^/  Bookmark key%-12c,  Pin CWD\n"
                "a1-4  Context 1-4%-7c(Sh)Tab  Cycle context\n"
                  "c/  Filter%-17c^N  Toggle type-to-nav\n"
                "aEsc  Exit prompt%-12c^L  Redraw/clear prompt\n"
-                 "c?  Help, conf%-14c+  Toggle auto-advance\n"
-                 "cq  Quit context%-11c^G  QuitCD\n"
-                "b^Q  Quit%-20cQ  Quit with err\n"
+                 "c0  Lock%-14cAlt+Esc  Clear filter, redraw\n"
+                 "c?  Help, conf%-13c^G  QuitCD\n"
+                 "cq  Quit context%-7c^Q (Q)  Quit (with err)\n"
                "1FILES\n"
               "9o ^O  Open with...%-12cn  Create new/link\n"
               "9f ^F  File details%-12cd  Detail mode toggle\n"