diff options
author | Arun Prakash Jana <engineerarun@gmail.com> | 2018-10-27 08:35:05 +0530 |
---|---|---|
committer | Arun Prakash Jana <engineerarun@gmail.com> | 2018-10-27 08:35:05 +0530 |
commit | c5a841f507b18045adabdaac16211fa191868a38 (patch) | |
tree | 24fddcd0e9eebe1d63b2f503be88c82ef9fd9a39 | |
parent | d14912dff655625a9d5e16ca94388b058c30fdb2 (diff) | |
download | nnn-c5a841f507b18045adabdaac16211fa191868a38.tar.gz |
Exit prompt on Escape press
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | nnn.1 | 4 | ||||
-rw-r--r-- | nnn.c | 18 |
3 files changed, 17 insertions, 6 deletions
@@ -249,6 +249,7 @@ optional args: y Show copy buffer ^T Toggle path quote ^L Redraw, clear prompt + Esc Exit prompt L Lock terminal o Open DE filemanager ^/ Open DE search app @@ -116,7 +116,9 @@ Show copy buffer .It Ic ^T Toggle path quote .It Ic ^L -Force a redraw, clear rename or filter prompt +Force a redraw, clear prompt +.It Ic Esc +Exit prompt .It Ic L Lock terminal (Linux only) .It Ic \&? @@ -1092,7 +1092,6 @@ static int filterentries(char *path) cur = 0; cleartimeout(); - echo(); curs_set(TRUE); printprompt(ln); @@ -1117,6 +1116,12 @@ static int filterentries(char *path) continue; } + if (*ch == 27) { /* Exit filter mode on Escape */ + cur = oldcur; + *ch = CONTROL('L'); + goto end; + } + if (r == OK) { /* Handle all control chars in main loop */ if (keyname(*ch)[0] == '^') { @@ -1186,7 +1191,6 @@ static int filterentries(char *path) } } end: - noecho(); curs_set(FALSE); settimeout(); @@ -1197,7 +1201,6 @@ end: /* Show a prompt with input string and return the changes */ static char *xreadline(char *fname, char *prompt) { - int old_curs = curs_set(1); size_t len, pos; int x, y, r; wint_t ch[2] = {0}; @@ -1217,6 +1220,7 @@ static char *xreadline(char *fname, char *prompt) } getyx(stdscr, y, x); + curs_set(TRUE); cleartimeout(); while (1) { @@ -1257,6 +1261,9 @@ static char *xreadline(char *fname, char *prompt) len -= pos; pos = 0; continue; + case 27: /* Exit prompt on Escape */ + len = 0; + goto END; } /* Filter out all other control chars */ @@ -1300,10 +1307,10 @@ static char *xreadline(char *fname, char *prompt) END: buf[len] = '\0'; - if (old_curs != ERR) - curs_set(old_curs); + curs_set(FALSE); settimeout(); + DPRINTF_S(buf); wcstombs(g_buf, buf, NAME_MAX); clearprompt(); @@ -1974,6 +1981,7 @@ static int show_help(char *path) "ey Show copy buffer\n" "d^T Toggle path quote\n" "d^L Redraw, clear prompt\n" + "cEsc Exit prompt\n" "eL Lock terminal\n" "eo Open DE filemanager\n" "d^/ Open DE search app\n" |