Key N to switch to context N

This commit is contained in:
Arun Prakash Jana 2019-01-19 13:09:46 +05:30
parent 5e4810b382
commit 5f581ff20a
No known key found for this signature in database
GPG key ID: A75979F35C080412
4 changed files with 22 additions and 7 deletions

View file

@ -216,7 +216,7 @@ Press <kbd>?</kbd> in `nnn` to see the list anytime.
/ Filter Ins, ^T Toggle nav-as-you-type / Filter Ins, ^T Toggle nav-as-you-type
b Pin current dir ^W Go to pinned dir b Pin current dir ^W Go to pinned dir
Tab, ^I Next context d Toggle detail view Tab, ^I Next context d Toggle detail view
`, ^/ Leader key LeaderN Go to/create context N `, ^/ Leader key N, LeadN Go to/create context N
Esc Exit prompt ^L Redraw/clear prompt Esc Exit prompt ^L Redraw/clear prompt
^G Quit and cd q Quit context ^G Quit and cd q Quit context
Q, ^Q Quit ? Help, config Q, ^Q Quit ? Help, config

2
nnn.1
View file

@ -67,7 +67,7 @@ Toggle detail view
Next context, ask to create if none Next context, ask to create if none
.It Ic `, ^/ .It Ic `, ^/
Leader key Leader key
.It Ic LeaderN .It Ic N, LeaderN
Switch to context N Switch to context N
.It Ic Esc .It Ic Esc
Exit prompt Exit prompt

View file

@ -2100,7 +2100,7 @@ static bool show_help(char *path)
"e/ Filter Ins, ^T Toggle nav-as-you-type\n" "e/ Filter Ins, ^T Toggle nav-as-you-type\n"
"eb Pin current dir ^W Go to pinned dir\n" "eb Pin current dir ^W Go to pinned dir\n"
"8Tab, ^I Next context d Toggle detail view\n" "8Tab, ^I Next context d Toggle detail view\n"
"a`, ^/ Leader key LeaderN Go to/create context N\n" "a`, ^/ Leader key N, LeadN Go to/create context N\n"
"cEsc Exit prompt ^L Redraw/clear prompt\n" "cEsc Exit prompt ^L Redraw/clear prompt\n"
"d^G Quit and cd q Quit context\n" "d^G Quit and cd q Quit context\n"
"aQ, ^Q Quit ? Help, config\n" "aQ, ^Q Quit ? Help, config\n"
@ -2874,9 +2874,15 @@ nochange:
setdirwatch(); setdirwatch();
goto begin; goto begin;
case SEL_LEADER: // fallthrough case SEL_LEADER: // fallthrough
case SEL_CYCLE: case SEL_CYCLE: // fallthrough
case SEL_CTX1: // fallthrough
case SEL_CTX2: // fallthrough
case SEL_CTX3: // fallthrough
case SEL_CTX4:
if (sel == SEL_CYCLE) if (sel == SEL_CYCLE)
fd = '>'; fd = '>';
else if (sel >= SEL_CTX1 && sel <= SEL_CTX4)
fd = sel - SEL_CTX1 + '1';
else else
fd = get_input(NULL); fd = get_input(NULL);
@ -2887,9 +2893,9 @@ nochange:
case '&': case '&':
presel = fd; presel = fd;
goto nochange; goto nochange;
case '>': case '>': // fallthrough
case '.': case '.': // fallthrough
case '<': case '<': // fallthrough
case ',': case ',':
r = cfg.curctx; r = cfg.curctx;
if (fd == '>' || fd == '.') if (fd == '>' || fd == '.')

View file

@ -50,6 +50,10 @@ enum action {
SEL_CDLAST, SEL_CDLAST,
SEL_LEADER, SEL_LEADER,
SEL_CYCLE, SEL_CYCLE,
SEL_CTX1,
SEL_CTX2,
SEL_CTX3,
SEL_CTX4,
SEL_PIN, SEL_PIN,
SEL_VISIT, SEL_VISIT,
SEL_FLTR, SEL_FLTR,
@ -145,6 +149,11 @@ static struct key bindings[] = {
/* Cycle contexts in forward direction */ /* Cycle contexts in forward direction */
{ '\t', SEL_CYCLE }, { '\t', SEL_CYCLE },
{ CONTROL('I'), SEL_CYCLE }, { CONTROL('I'), SEL_CYCLE },
/* Go to/create context N */
{ '1', SEL_CTX1 },
{ '2', SEL_CTX2 },
{ '3', SEL_CTX3 },
{ '4', SEL_CTX4 },
/* Mark a path to visit later */ /* Mark a path to visit later */
{ 'b', SEL_PIN }, { 'b', SEL_PIN },
/* Visit marked directory */ /* Visit marked directory */