mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Support key q for context quit
This commit is contained in:
parent
fe9e8a62bf
commit
8a9319fb79
|
@ -252,15 +252,16 @@ optional args:
|
|||
L Lock terminal
|
||||
o Launch GUI app
|
||||
? Help, settings
|
||||
Q, ^G Quit and cd
|
||||
q, ^X Quit
|
||||
q Quit context
|
||||
^G Quit and cd
|
||||
Q, ^X Quit
|
||||
```
|
||||
|
||||
Help & settings, file details, media info and archive listing are shown in the PAGER. Please use the PAGER-specific keys in these screens.
|
||||
|
||||
#### Contexts
|
||||
|
||||
Contexts (aka _tabs_ aka _workspaces_) serve the purpose of exploring multiple directories in parallel. `nnn` provides 4 contexts simultaneously. The status of the contexts are shown in the top left corner:
|
||||
Contexts (aka _tabs_ aka _workspaces_) serve the purpose of exploring multiple directories simultaneously. 4 contexts are available. The status of the contexts are shown in the top left corner:
|
||||
|
||||
- the current context is in reverse
|
||||
- other used contexts are underlined
|
||||
|
@ -270,6 +271,8 @@ The bookmark prompt understands contexts. To switch contexts press `^B` and ente
|
|||
|
||||
The first time a context is entered, it copies the state of the last visited context. Each context remembers its start directory and last visited directory.
|
||||
|
||||
When a context is quit, the next active context is selected. If the last active context is quit, the program quits.
|
||||
|
||||
#### Filters
|
||||
|
||||
Filters support regexes to instantly (search-as-you-type) list the matching entries in the current directory.
|
||||
|
|
13
nnn.1
13
nnn.1
|
@ -119,9 +119,11 @@ Lock terminal (Linux only)
|
|||
Launch a GUI application
|
||||
.It Ic \&?
|
||||
Toggle help and settings screen
|
||||
.It Ic Q, ^G
|
||||
.It Ic q
|
||||
Quit the current context
|
||||
.It Ic ^G
|
||||
Quit and change directory
|
||||
.It Ic q, ^X
|
||||
.It Ic Q, ^X
|
||||
Quit
|
||||
.El
|
||||
.Pp
|
||||
|
@ -181,9 +183,8 @@ to change to the last visited directory on quit requires shell integration in a
|
|||
few easy steps. Please visit the project page (linked below) for the
|
||||
instructions.
|
||||
.Sh CONTEXTS
|
||||
Contexts (aka \fItabs\fR aka \fIworkspaces\fR) serve the purpose of exploring multiple directories in parallel.
|
||||
.Nm
|
||||
provides 4 contexts simultaneously. The status of the contexts are shown in the top left corner:
|
||||
Contexts (aka \fItabs\fR aka \fIworkspaces\fR) serve the purpose of exploring multiple directories
|
||||
simultaneously. 4 contexts are available. The status of the contexts are shown in the top left corner:
|
||||
.Pp
|
||||
- the current context is in reverse
|
||||
.br
|
||||
|
@ -194,6 +195,8 @@ provides 4 contexts simultaneously. The status of the contexts are shown in the
|
|||
The bookmark prompt understands contexts. To switch contexts press \fI^B\fR and enter the context number (1-4).
|
||||
.Pp
|
||||
The first time a context is entered, it copies the state of the last visited context. Each context remembers its start directory and last visited directory.
|
||||
.Pp
|
||||
When a context is quit, the next active context is selected. If the last active context is quit, the program quits.
|
||||
.Sh FILTERS
|
||||
Filters support regexes to instantly (search-as-you-type) list the matching
|
||||
entries in the current directory.
|
||||
|
|
77
nnn.c
77
nnn.c
|
@ -1988,8 +1988,9 @@ static int show_help(char *path)
|
|||
"eL Lock terminal\n"
|
||||
"eo Launch GUI app\n"
|
||||
"e? Help, settings\n"
|
||||
"aQ, ^G Quit and cd\n"
|
||||
"aq, ^X Quit\n\n"};
|
||||
"eq Quit context\n"
|
||||
"d^G Quit and cd\n"
|
||||
"aQ, ^X Quit\n\n"};
|
||||
|
||||
if (fd == -1)
|
||||
return -1;
|
||||
|
@ -2708,7 +2709,7 @@ nochange:
|
|||
tmp = lastdir;
|
||||
|
||||
if (tmp[0] == '\0') {
|
||||
printmsg("not set...");
|
||||
printmsg("not set");
|
||||
goto nochange;
|
||||
}
|
||||
|
||||
|
@ -2744,8 +2745,8 @@ nochange:
|
|||
case '3': //fallthrough
|
||||
case '4':
|
||||
{
|
||||
uint nextctx = tmp[0] - '1';
|
||||
if (g_curctx == nextctx)
|
||||
r = tmp[0] - '1'; /* Save the next context id */
|
||||
if (g_curctx == r)
|
||||
continue;
|
||||
|
||||
g_crc = 0;
|
||||
|
@ -2757,27 +2758,29 @@ nochange:
|
|||
xstrlcpy(g_ctx[g_curctx].c_last, lastdir, PATH_MAX);
|
||||
g_ctx[g_curctx].c_cfg = cfg;
|
||||
|
||||
if (!g_ctx[nextctx].c_cfg.ctxactive) {
|
||||
if (!g_ctx[r].c_cfg.ctxactive) {
|
||||
/* Setup a new context from current context */
|
||||
g_ctx[nextctx].c_cfg.ctxactive = 1;
|
||||
xstrlcpy(g_ctx[nextctx].c_name, oldname, NAME_MAX + 1);
|
||||
xstrlcpy(g_ctx[nextctx].c_fltr, fltr, NAME_MAX + 1);
|
||||
xstrlcpy(g_ctx[nextctx].c_path, path, PATH_MAX);
|
||||
xstrlcpy(g_ctx[nextctx].c_init, path, PATH_MAX);
|
||||
ipath = g_ctx[nextctx].c_init;
|
||||
g_ctx[nextctx].c_last[0] = lastdir[0] = '\0';
|
||||
g_ctx[nextctx].c_cfg = cfg;
|
||||
g_ctx[r].c_cfg.ctxactive = 1;
|
||||
xstrlcpy(g_ctx[r].c_name, oldname, NAME_MAX + 1);
|
||||
xstrlcpy(g_ctx[r].c_fltr, fltr, NAME_MAX + 1);
|
||||
xstrlcpy(g_ctx[r].c_path, path, PATH_MAX);
|
||||
xstrlcpy(g_ctx[r].c_init, path, PATH_MAX);
|
||||
ipath = g_ctx[r].c_init;
|
||||
g_ctx[r].c_last[0] = lastdir[0] = '\0';
|
||||
g_ctx[r].c_cfg = cfg;
|
||||
} else {
|
||||
/* Switch to saved context */
|
||||
xstrlcpy(oldname, g_ctx[nextctx].c_name, NAME_MAX + 1);
|
||||
xstrlcpy(fltr, g_ctx[nextctx].c_fltr, NAME_MAX + 1);
|
||||
xstrlcpy(path, g_ctx[nextctx].c_path, PATH_MAX);
|
||||
ipath = g_ctx[nextctx].c_init;
|
||||
xstrlcpy(lastdir, g_ctx[nextctx].c_last, PATH_MAX);
|
||||
cfg = g_ctx[nextctx].c_cfg;
|
||||
xstrlcpy(oldname, g_ctx[r].c_name, NAME_MAX + 1);
|
||||
xstrlcpy(fltr, g_ctx[r].c_fltr, NAME_MAX + 1);
|
||||
xstrlcpy(path, g_ctx[r].c_path, PATH_MAX);
|
||||
ipath = g_ctx[r].c_init;
|
||||
xstrlcpy(lastdir, g_ctx[r].c_last, PATH_MAX);
|
||||
cfg = g_ctx[r].c_cfg;
|
||||
}
|
||||
|
||||
g_curctx = nextctx;
|
||||
g_curctx = r;
|
||||
if (cfg.filtermode)
|
||||
presel = FILTER;
|
||||
goto begin;
|
||||
}
|
||||
}
|
||||
|
@ -3281,6 +3284,38 @@ nochange:
|
|||
case SEL_LOCK:
|
||||
spawn(player, "", "screensaver", NULL, F_NORMAL | F_SIGINT);
|
||||
break;
|
||||
case SEL_QUITCTX:
|
||||
{
|
||||
uint iter = 1;
|
||||
r = g_curctx;
|
||||
while (iter < MAX_CTX) {
|
||||
++r;
|
||||
r %= MAX_CTX;
|
||||
DPRINTF_D(r);
|
||||
DPRINTF_U(g_ctx[r].c_cfg.ctxactive);
|
||||
if (g_ctx[r].c_cfg.ctxactive) {
|
||||
g_ctx[g_curctx].c_cfg.ctxactive = 0;
|
||||
|
||||
/* Switch to next active context */
|
||||
xstrlcpy(oldname, g_ctx[r].c_name, NAME_MAX + 1);
|
||||
xstrlcpy(fltr, g_ctx[r].c_fltr, NAME_MAX + 1);
|
||||
xstrlcpy(path, g_ctx[r].c_path, PATH_MAX);
|
||||
ipath = g_ctx[r].c_init;
|
||||
xstrlcpy(lastdir, g_ctx[r].c_last, PATH_MAX);
|
||||
cfg = g_ctx[r].c_cfg;
|
||||
|
||||
g_curctx = r;
|
||||
if (cfg.filtermode)
|
||||
presel = FILTER;
|
||||
goto begin;
|
||||
}
|
||||
|
||||
++iter;
|
||||
}
|
||||
|
||||
dentfree(dents);
|
||||
return;
|
||||
}
|
||||
case SEL_CDQUIT:
|
||||
{
|
||||
tmp = getenv("NNN_TMPFILE");
|
||||
|
|
6
nnn.h
6
nnn.h
|
@ -79,6 +79,7 @@ enum action {
|
|||
SEL_RUNSCRIPT,
|
||||
SEL_RUNARG,
|
||||
SEL_LOCK,
|
||||
SEL_QUITCTX,
|
||||
SEL_CDQUIT,
|
||||
SEL_QUIT,
|
||||
};
|
||||
|
@ -214,10 +215,11 @@ static struct key bindings[] = {
|
|||
{ 'p', SEL_RUNARG, "less", "PAGER" },
|
||||
/* Lock screen */
|
||||
{ 'L', SEL_LOCK, "", "" },
|
||||
/* Quit a context */
|
||||
{ 'q', SEL_QUITCTX, "", "" },
|
||||
/* Change dir on quit */
|
||||
{ 'Q', SEL_CDQUIT, "", "" },
|
||||
{ CONTROL('G'), SEL_CDQUIT, "", "" },
|
||||
/* Quit */
|
||||
{ 'q', SEL_QUIT, "", "" },
|
||||
{ 'Q', SEL_QUIT, "", "" },
|
||||
{ CONTROL('X'), SEL_QUIT, "", "" },
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue