Skip to content

Commit

Permalink
Add option to not move to next entry on select (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
FriendlyNeighborhoodShane authored and jarun committed Aug 29, 2020
1 parent 279f36f commit b92999c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions nnn.1
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
.Op Ar -F
.Op Ar -g
.Op Ar -H
.Op Ar -J
.Op Ar -K
.Op Ar -l
.Op Ar -n
Expand Down Expand Up @@ -95,6 +96,9 @@ supports the following options:
.Fl H
show hidden files
.Pp
.Fl J
disable auto-proceed on select
.Pp
.Fl K
test for keybind collision
.Pp
Expand Down
9 changes: 7 additions & 2 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ typedef struct {
uint selmode : 1; /* Set when selecting files */
uint oldcolor : 1; /* Show dirs in context colors */
uint reserved : 14;
uint stayonsel : 1; /* Disable auto-proceed on select */
} runstate;

/* Contexts or workspaces */
Expand Down Expand Up @@ -6461,7 +6462,7 @@ static bool browse(char *ipath, const char *session, int pkey)
else
#endif
/* move cursor to the next entry if this is not the last entry */
if (!g_state.picker && cur != ndents - 1)
if (!g_state.stayonsel && !g_state.picker && cur != ndents - 1)
move_cursor((cur + 1) % ndents, 0);
break;
case SEL_SELMUL:
Expand Down Expand Up @@ -7256,6 +7257,7 @@ static void usage(void)
" -F show fortune\n"
" -g regex filters [default: string]\n"
" -H show hidden files\n"
" -J no auto-proceed on select"
" -K detect key collision\n"
" -l val set scroll lines\n"
" -n type-to-nav mode\n"
Expand Down Expand Up @@ -7417,7 +7419,7 @@ int main(int argc, char *argv[])

while ((opt = (env_opts_id > 0
? env_opts[--env_opts_id]
: getopt(argc, argv, "aAb:cCdeEfFgHKl:nop:P:QrRs:St:T:uVwxh"))) != -1) {
: getopt(argc, argv, "aAb:cCdeEfFgHJKl:nop:P:QrRs:St:T:uVwxh"))) != -1) {
switch (opt) {
#ifndef NOFIFO
case 'a':
Expand Down Expand Up @@ -7462,6 +7464,9 @@ int main(int argc, char *argv[])
case 'H':
cfg.showhidden = 1;
break;
case 'J':
g_state.stayonsel = 1;
break;
case 'K':
check_key_collision();
return EXIT_SUCCESS;
Expand Down

0 comments on commit b92999c

Please sign in to comment.