Skip to content

Commit

Permalink
Fix jarun#775: quit on double Esc
Browse files Browse the repository at this point in the history
  • Loading branch information
jarun committed Nov 10, 2020
1 parent 1418ecd commit c674cb5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
30 changes: 20 additions & 10 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,9 @@ static int (*nftw_fn)(const char *fpath, const struct stat *sb, int typeflag, st
static void move_cursor(int target, int ignore_scrolloff);
static char *load_input(int fd, const char *path);
static int set_sort_flags(int r);
#ifndef NOFIFO
static void notify_fifo(bool force);
#endif

/* Functions */

Expand Down Expand Up @@ -2549,8 +2552,10 @@ static int nextsel(int presel)
#endif
int c = presel;
uint i;
bool escaped = FALSE;

if (c == 0 || c == MSGWAIT) {
try_quit:
c = getch();
//DPRINTF_D(c);
//DPRINTF_S(keyname(c));
Expand All @@ -2566,9 +2571,19 @@ static int nextsel(int presel)
ungetch(c);
c = ';';
}
} else
c = ESC;
settimeout();
settimeout();
} else if (escaped) {
settimeout();
c = CONTROL('Q');
} else {
#ifndef NOFIFO
/* Send hovered path to NNN_FIFO */
notify_fifo(TRUE);
#endif
escaped = TRUE;
settimeout();
goto try_quit;
}
}

if (c == ERR && presel == MSGWAIT)
Expand Down Expand Up @@ -4582,7 +4597,7 @@ static void show_help(const char *path)
"a1-4 Context 1-4%-7c(Sh)Tab Cycle context\n"
"aEsc Send to FIFO%-11c^L Redraw\n"
"c? Help, conf%-13c^G QuitCD\n"
"cq Quit context%-7c^Q (Q) Quit (with err)\n"
"2^Q 2Esc (Q) Quit (with err)%-9cq Quit context\n"
"1FILTER & PROMPT\n"
"c/ Filter%-12cAlt+Esc Clear filter & redraw\n"
"aEsc Exit prompt%-12c^L Clear prompt/last filter\n"
Expand All @@ -4593,7 +4608,7 @@ static void show_help(const char *path)
"b^R Rename/dup%-14cr Batch rename\n"
"cz Archive%-17ce Edit file\n"
"c* Toggle exe%-14c> Export list\n"
"5Space ^J (Un)select%-7cm ^Space Mark range/clear\n"
"5Space ^J (Un)select%-7cm ^Space Mark range/clear sel\n"
"9p ^P Copy sel here%-11ca Select all\n"
"9v ^V Move sel here%-8cw ^W Cp/mv sel as\n"
"9x ^X Delete%-18cE Edit sel\n"
Expand Down Expand Up @@ -7068,11 +7083,6 @@ static bool browse(char *ipath, const char *session, int pkey)
selbufpos = 0;
}
return sel == SEL_QUITFAIL ? EXIT_FAILURE : EXIT_SUCCESS;
#ifndef NOFIFO
case SEL_FIFO:
notify_fifo(TRUE);
goto nochange;
#endif
default:
if (xlines != LINES || xcols != COLS)
continue;
Expand Down
7 changes: 0 additions & 7 deletions src/nnn.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ enum action {
SEL_QUITCD,
SEL_QUIT,
SEL_QUITFAIL,
#ifndef NOFIFO
SEL_FIFO,
#endif
#ifndef NOMOUSE
SEL_CLICK,
#endif
Expand Down Expand Up @@ -274,10 +271,6 @@ static struct key bindings[] = {
{ CONTROL('Q'), SEL_QUIT },
/* Quit with an error code */
{ 'Q', SEL_QUITFAIL },
#ifndef NOFIFO
/* Send hovered path to NNN_FIFO */
{ ESC, SEL_FIFO },
#endif
#ifndef NOMOUSE
{ KEY_MOUSE, SEL_CLICK },
#endif
Expand Down

0 comments on commit c674cb5

Please sign in to comment.