Option -R to disable rollover at edges

This commit is contained in:
Arun Prakash Jana 2019-12-01 23:00:06 +05:30
parent feb1d2fc27
commit 3f0c604111
No known key found for this signature in database
GPG Key ID: A75979F35C080412
6 changed files with 19 additions and 5 deletions

View File

@ -189,6 +189,7 @@ optional args:
-o open files on Enter -o open files on Enter
-p file selection file [stdout if '-'] -p file selection file [stdout if '-']
-r use advcpmv patched cp, mv -r use advcpmv patched cp, mv
-R disable rollover at edges
-s string filters [default: regex] -s string filters [default: regex]
-S du mode -S du mode
-t disable dir auto-select -t disable dir auto-select

View File

@ -26,6 +26,7 @@ _nnn ()
-o -o
-p -p
-r -r
-R
-s -s
-S -S
-t -t

View File

@ -25,6 +25,7 @@ complete -c nnn -s n -d 'use version compare to sort files'
complete -c nnn -s o -d 'open files only on Enter' complete -c nnn -s o -d 'open files only on Enter'
complete -c nnn -s p -r -d 'copy selection to file' -a '-\tstdout' complete -c nnn -s p -r -d 'copy selection to file' -a '-\tstdout'
complete -c nnn -s r -d 'show cp, mv progress (Linux-only)' complete -c nnn -s r -d 'show cp, mv progress (Linux-only)'
complete -c nnn -s R -d 'disable rollover at edges'
complete -c nnn -s s -d 'use substring match for filters' complete -c nnn -s s -d 'use substring match for filters'
complete -c nnn -s S -d 'start in disk usage analyzer mode' complete -c nnn -s S -d 'start in disk usage analyzer mode'
complete -c nnn -s t -d 'disable dir auto-select' complete -c nnn -s t -d 'disable dir auto-select'

View File

@ -23,6 +23,7 @@ args=(
'(-o)-o[open files only on Enter]' '(-o)-o[open files only on Enter]'
'(-p)-p[copy selection to file]:file name' '(-p)-p[copy selection to file]:file name'
'(-r)-r[show cp, mv progress (Linux-only)]' '(-r)-r[show cp, mv progress (Linux-only)]'
'(-R)-R[disable rollover at edges]'
'(-s)-s[use substring match for filters]' '(-s)-s[use substring match for filters]'
'(-S)-S[start in disk usage analyzer mode]' '(-S)-S[start in disk usage analyzer mode]'
'(-t)-t[disable dir auto-select]' '(-t)-t[disable dir auto-select]'

4
nnn.1
View File

@ -19,6 +19,7 @@
.Op Ar -n .Op Ar -n
.Op Ar -p file .Op Ar -p file
.Op Ar -r .Op Ar -r
.Op Ar -R
.Op Ar -s .Op Ar -s
.Op Ar -S .Op Ar -S
.Op Ar -v .Op Ar -v
@ -84,6 +85,9 @@ supports the following options:
.Fl r .Fl r
show cp, mv progress (Linux-only, needs advcpmv; '^T' shows the progress on BSD/macOS) show cp, mv progress (Linux-only, needs advcpmv; '^T' shows the progress on BSD/macOS)
.Pp .Pp
.Fl R
disable rollover at edges
.Pp
.Fl s .Fl s
use substring match for filters instead of regex use substring match for filters instead of regex
.Pp .Pp

View File

@ -227,7 +227,7 @@ typedef struct {
uint selmode : 1; /* Set when selecting files */ uint selmode : 1; /* Set when selecting files */
uint showdetail : 1; /* Clear to show fewer file info */ uint showdetail : 1; /* Clear to show fewer file info */
uint ctxactive : 1; /* Context active or not */ uint ctxactive : 1; /* Context active or not */
uint reserved : 4; uint reserved : 3;
/* The following settings are global */ /* The following settings are global */
uint curctx : 2; /* Current context number */ uint curctx : 2; /* Current context number */
uint dircolor : 1; /* Current status of dir color */ uint dircolor : 1; /* Current status of dir color */
@ -245,6 +245,7 @@ typedef struct {
uint mtime : 1; /* Use modification time (else access time) */ uint mtime : 1; /* Use modification time (else access time) */
uint cliopener : 1; /* All-CLI app opener */ uint cliopener : 1; /* All-CLI app opener */
uint waitedit : 1; /* For ops that can't be detached, used EDITOR */ uint waitedit : 1; /* For ops that can't be detached, used EDITOR */
uint rollover : 1; /* Roll over at edges */
} settings; } settings;
/* Contexts or workspaces */ /* Contexts or workspaces */
@ -296,6 +297,7 @@ static settings cfg = {
1, /* mtime */ 1, /* mtime */
0, /* cliopener */ 0, /* cliopener */
0, /* waitedit */ 0, /* waitedit */
1, /* rollover */
}; };
static context g_ctx[CTX_MAX] __attribute__ ((aligned)); static context g_ctx[CTX_MAX] __attribute__ ((aligned));
@ -3937,17 +3939,17 @@ static void move_cursor(int target, int ignore_scrolloff)
curscroll = MAX(curscroll, MAX(cur - (onscreen - 1), 0)); curscroll = MAX(curscroll, MAX(cur - (onscreen - 1), 0));
} }
static void handle_screen_move(enum action sel) static inline void handle_screen_move(enum action sel)
{ {
int onscreen; int onscreen;
switch (sel) { switch (sel) {
case SEL_NEXT: case SEL_NEXT:
if (ndents) if (ndents && (cfg.rollover || (cur != ndents - 1)))
move_cursor((cur + 1) % ndents, 0); move_cursor((cur + 1) % ndents, 0);
break; break;
case SEL_PREV: case SEL_PREV:
if (ndents) if (ndents && (cfg.rollover || cur))
move_cursor((cur + ndents - 1) % ndents, 0); move_cursor((cur + ndents - 1) % ndents, 0);
break; break;
case SEL_PGDN: case SEL_PGDN:
@ -5415,6 +5417,7 @@ static void usage(void)
" -o open files on Enter\n" " -o open files on Enter\n"
" -p file selection file [stdout if '-']\n" " -p file selection file [stdout if '-']\n"
" -r use advcpmv patched cp, mv\n" " -r use advcpmv patched cp, mv\n"
" -R disable rollover at edges\n"
" -s string filters [default: regex]\n" " -s string filters [default: regex]\n"
" -S du mode\n" " -S du mode\n"
" -t disable dir auto-select\n" " -t disable dir auto-select\n"
@ -5561,7 +5564,7 @@ int main(int argc, char *argv[])
bool progress = FALSE; bool progress = FALSE;
#endif #endif
while ((opt = getopt(argc, argv, "HSKiab:cde:Efnop:rstvh")) != -1) { while ((opt = getopt(argc, argv, "HSKiab:cde:Efnop:rRstvh")) != -1) {
switch (opt) { switch (opt) {
case 'S': case 'S':
cfg.blkorder = 1; cfg.blkorder = 1;
@ -5623,6 +5626,9 @@ int main(int argc, char *argv[])
progress = TRUE; progress = TRUE;
#endif #endif
break; break;
case 'R':
cfg.rollover = 0;
break;
case 's': case 's':
cfg.filter_re = 0; cfg.filter_re = 0;
filterfn = &visible_str; filterfn = &visible_str;