mirror of
https://github.com/jarun/nnn.git
synced 2024-11-28 05:41:31 +00:00
Q - error & quit if no selection, else pick & quit
This commit is contained in:
parent
b09adb4654
commit
74cd15c232
|
@ -37,6 +37,7 @@ It runs smoothly on the Pi, [Termux](https://www.youtube.com/embed/AbaauM7gUJw)
|
||||||
<details><summary><i><b>Expand</b></i> for some nnn magic! :dark_sunglasses:</summary><br><ul>
|
<details><summary><i><b>Expand</b></i> for some nnn magic! :dark_sunglasses:</summary><br><ul>
|
||||||
<li>Instantly load, sort, filter thousands of files</li>
|
<li>Instantly load, sort, filter thousands of files</li>
|
||||||
<li>Type to navigate with automatic dir selection</li>
|
<li>Type to navigate with automatic dir selection</li>
|
||||||
|
<li>List input stream and pick entries to stdout or file</li>
|
||||||
<li>find/fd/grep/ripgrep/fzf from nnn and list in nnn</li>
|
<li>find/fd/grep/ripgrep/fzf from nnn and list in nnn</li>
|
||||||
<li> Never lose context - start where you quit</li>
|
<li> Never lose context - start where you quit</li>
|
||||||
<li>Mount any cloud storage service in a few keypresses</li>
|
<li>Mount any cloud storage service in a few keypresses</li>
|
||||||
|
|
16
src/nnn.c
16
src/nnn.c
|
@ -4602,6 +4602,7 @@ static void show_help(const char *path)
|
||||||
"aEsc Send to FIFO%-11c^L Redraw\n"
|
"aEsc Send to FIFO%-11c^L Redraw\n"
|
||||||
"c? Help, conf%-13c^G QuitCD\n"
|
"c? Help, conf%-13c^G QuitCD\n"
|
||||||
"cq Quit context%-6c^Q 2Esc Quit\n"
|
"cq Quit context%-6c^Q 2Esc Quit\n"
|
||||||
|
"cQ Pick sel/err & quit\n"
|
||||||
"1FILTER & PROMPT\n"
|
"1FILTER & PROMPT\n"
|
||||||
"c/ Filter%-12cAlt+Esc Clear filter & redraw\n"
|
"c/ Filter%-12cAlt+Esc Clear filter & redraw\n"
|
||||||
"aEsc Exit prompt%-12c^L Clear prompt/last filter\n"
|
"aEsc Exit prompt%-12c^L Clear prompt/last filter\n"
|
||||||
|
@ -7036,7 +7037,7 @@ nochange:
|
||||||
case SEL_QUITCTX: // fallthrough
|
case SEL_QUITCTX: // fallthrough
|
||||||
case SEL_QUITCD: // fallthrough
|
case SEL_QUITCD: // fallthrough
|
||||||
case SEL_QUIT:
|
case SEL_QUIT:
|
||||||
case SEL_QUITFAIL:
|
case SEL_QUITERR:
|
||||||
if (sel == SEL_QUITCTX) {
|
if (sel == SEL_QUITCTX) {
|
||||||
int ctx = cfg.curctx;
|
int ctx = cfg.curctx;
|
||||||
for (r = (ctx + 1) & ~CTX_MAX;
|
for (r = (ctx + 1) & ~CTX_MAX;
|
||||||
|
@ -7086,7 +7087,16 @@ nochange:
|
||||||
if (g_state.picker)
|
if (g_state.picker)
|
||||||
selbufpos = 0;
|
selbufpos = 0;
|
||||||
}
|
}
|
||||||
return sel == SEL_QUITFAIL ? EXIT_FAILURE : EXIT_SUCCESS;
|
|
||||||
|
if (sel != SEL_QUITERR)
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
|
if (selbufpos && !g_state.picker) {
|
||||||
|
g_state.pickraw = 1;
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_FAILURE;
|
||||||
default:
|
default:
|
||||||
if (xlines != LINES || xcols != COLS)
|
if (xlines != LINES || xcols != COLS)
|
||||||
continue;
|
continue;
|
||||||
|
@ -7926,7 +7936,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (g_state.pickraw || g_state.picker) {
|
if (g_state.pickraw || g_state.picker) {
|
||||||
if (selbufpos) {
|
if (selbufpos) {
|
||||||
fd = g_state.pickraw ? 1 : open(selpath, O_WRONLY | O_CREAT, 0600);
|
fd = g_state.pickraw ? STDOUT_FILENO : open(selpath, O_WRONLY | O_CREAT, 0600);
|
||||||
if ((fd == -1) || (seltofile(fd, NULL) != (size_t)(selbufpos)))
|
if ((fd == -1) || (seltofile(fd, NULL) != (size_t)(selbufpos)))
|
||||||
xerror();
|
xerror();
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ enum action {
|
||||||
SEL_QUITCTX,
|
SEL_QUITCTX,
|
||||||
SEL_QUITCD,
|
SEL_QUITCD,
|
||||||
SEL_QUIT,
|
SEL_QUIT,
|
||||||
SEL_QUITFAIL,
|
SEL_QUITERR,
|
||||||
#ifndef NOMOUSE
|
#ifndef NOMOUSE
|
||||||
SEL_CLICK,
|
SEL_CLICK,
|
||||||
#endif
|
#endif
|
||||||
|
@ -270,7 +270,7 @@ static struct key bindings[] = {
|
||||||
/* Quit */
|
/* Quit */
|
||||||
{ CONTROL('Q'), SEL_QUIT },
|
{ CONTROL('Q'), SEL_QUIT },
|
||||||
/* Quit with an error code */
|
/* Quit with an error code */
|
||||||
{ 'Q', SEL_QUITFAIL },
|
{ 'Q', SEL_QUITERR },
|
||||||
#ifndef NOMOUSE
|
#ifndef NOMOUSE
|
||||||
{ KEY_MOUSE, SEL_CLICK },
|
{ KEY_MOUSE, SEL_CLICK },
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue