mirror of
https://github.com/jarun/nnn.git
synced 2025-01-24 17:56:41 +00:00
Exit prompt on Escape press
This commit is contained in:
parent
d14912dff6
commit
c5a841f507
|
@ -249,6 +249,7 @@ optional args:
|
||||||
y Show copy buffer
|
y Show copy buffer
|
||||||
^T Toggle path quote
|
^T Toggle path quote
|
||||||
^L Redraw, clear prompt
|
^L Redraw, clear prompt
|
||||||
|
Esc Exit prompt
|
||||||
L Lock terminal
|
L Lock terminal
|
||||||
o Open DE filemanager
|
o Open DE filemanager
|
||||||
^/ Open DE search app
|
^/ Open DE search app
|
||||||
|
|
4
nnn.1
4
nnn.1
|
@ -116,7 +116,9 @@ Show copy buffer
|
||||||
.It Ic ^T
|
.It Ic ^T
|
||||||
Toggle path quote
|
Toggle path quote
|
||||||
.It Ic ^L
|
.It Ic ^L
|
||||||
Force a redraw, clear rename or filter prompt
|
Force a redraw, clear prompt
|
||||||
|
.It Ic Esc
|
||||||
|
Exit prompt
|
||||||
.It Ic L
|
.It Ic L
|
||||||
Lock terminal (Linux only)
|
Lock terminal (Linux only)
|
||||||
.It Ic \&?
|
.It Ic \&?
|
||||||
|
|
18
nnn.c
18
nnn.c
|
@ -1092,7 +1092,6 @@ static int filterentries(char *path)
|
||||||
cur = 0;
|
cur = 0;
|
||||||
|
|
||||||
cleartimeout();
|
cleartimeout();
|
||||||
echo();
|
|
||||||
curs_set(TRUE);
|
curs_set(TRUE);
|
||||||
printprompt(ln);
|
printprompt(ln);
|
||||||
|
|
||||||
|
@ -1117,6 +1116,12 @@ static int filterentries(char *path)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*ch == 27) { /* Exit filter mode on Escape */
|
||||||
|
cur = oldcur;
|
||||||
|
*ch = CONTROL('L');
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
if (r == OK) {
|
if (r == OK) {
|
||||||
/* Handle all control chars in main loop */
|
/* Handle all control chars in main loop */
|
||||||
if (keyname(*ch)[0] == '^') {
|
if (keyname(*ch)[0] == '^') {
|
||||||
|
@ -1186,7 +1191,6 @@ static int filterentries(char *path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
noecho();
|
|
||||||
curs_set(FALSE);
|
curs_set(FALSE);
|
||||||
settimeout();
|
settimeout();
|
||||||
|
|
||||||
|
@ -1197,7 +1201,6 @@ end:
|
||||||
/* Show a prompt with input string and return the changes */
|
/* Show a prompt with input string and return the changes */
|
||||||
static char *xreadline(char *fname, char *prompt)
|
static char *xreadline(char *fname, char *prompt)
|
||||||
{
|
{
|
||||||
int old_curs = curs_set(1);
|
|
||||||
size_t len, pos;
|
size_t len, pos;
|
||||||
int x, y, r;
|
int x, y, r;
|
||||||
wint_t ch[2] = {0};
|
wint_t ch[2] = {0};
|
||||||
|
@ -1217,6 +1220,7 @@ static char *xreadline(char *fname, char *prompt)
|
||||||
}
|
}
|
||||||
|
|
||||||
getyx(stdscr, y, x);
|
getyx(stdscr, y, x);
|
||||||
|
curs_set(TRUE);
|
||||||
cleartimeout();
|
cleartimeout();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -1257,6 +1261,9 @@ static char *xreadline(char *fname, char *prompt)
|
||||||
len -= pos;
|
len -= pos;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
continue;
|
continue;
|
||||||
|
case 27: /* Exit prompt on Escape */
|
||||||
|
len = 0;
|
||||||
|
goto END;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Filter out all other control chars */
|
/* Filter out all other control chars */
|
||||||
|
@ -1300,10 +1307,10 @@ static char *xreadline(char *fname, char *prompt)
|
||||||
|
|
||||||
END:
|
END:
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
if (old_curs != ERR)
|
|
||||||
curs_set(old_curs);
|
|
||||||
|
|
||||||
|
curs_set(FALSE);
|
||||||
settimeout();
|
settimeout();
|
||||||
|
|
||||||
DPRINTF_S(buf);
|
DPRINTF_S(buf);
|
||||||
wcstombs(g_buf, buf, NAME_MAX);
|
wcstombs(g_buf, buf, NAME_MAX);
|
||||||
clearprompt();
|
clearprompt();
|
||||||
|
@ -1974,6 +1981,7 @@ static int show_help(char *path)
|
||||||
"ey Show copy buffer\n"
|
"ey Show copy buffer\n"
|
||||||
"d^T Toggle path quote\n"
|
"d^T Toggle path quote\n"
|
||||||
"d^L Redraw, clear prompt\n"
|
"d^L Redraw, clear prompt\n"
|
||||||
|
"cEsc Exit prompt\n"
|
||||||
"eL Lock terminal\n"
|
"eL Lock terminal\n"
|
||||||
"eo Open DE filemanager\n"
|
"eo Open DE filemanager\n"
|
||||||
"d^/ Open DE search app\n"
|
"d^/ Open DE search app\n"
|
||||||
|
|
Loading…
Reference in a new issue