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
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.
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
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
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.
"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;
tmp = lastdir;
if (tmp[0] == '\0') {
- printmsg("not set...");
+ printmsg("not set");
goto 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;
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;
}
}
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");
SEL_RUNSCRIPT,
SEL_RUNARG,
SEL_LOCK,
+ SEL_QUITCTX,
SEL_CDQUIT,
SEL_QUIT,
};
{ '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, "", "" },
};