aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-12-01 23:00:06 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-12-01 23:00:06 +0530
commit3f0c604111ee8d16afaa26824cae5db070c30cff (patch)
treeff1314d57fcbeb86cdfc3330238c15e05119f1fd /src
parentfeb1d2fc272f044a370eb79d29c03b543938ffa1 (diff)
downloadnnn-3f0c604111ee8d16afaa26824cae5db070c30cff.tar.gz
Option -R to disable rollover at edges
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/nnn.c b/src/nnn.c
index d8a240d..3d8db0e 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -227,7 +227,7 @@ typedef struct {
uint selmode : 1; /* Set when selecting files */
uint showdetail : 1; /* Clear to show fewer file info */
uint ctxactive : 1; /* Context active or not */
- uint reserved : 4;
+ uint reserved : 3;
/* The following settings are global */
uint curctx : 2; /* Current context number */
uint dircolor : 1; /* Current status of dir color */
@@ -245,6 +245,7 @@ typedef struct {
uint mtime : 1; /* Use modification time (else access time) */
uint cliopener : 1; /* All-CLI app opener */
uint waitedit : 1; /* For ops that can't be detached, used EDITOR */
+ uint rollover : 1; /* Roll over at edges */
} settings;
/* Contexts or workspaces */
@@ -296,6 +297,7 @@ static settings cfg = {
1, /* mtime */
0, /* cliopener */
0, /* waitedit */
+ 1, /* rollover */
};
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));
}
-static void handle_screen_move(enum action sel)
+static inline void handle_screen_move(enum action sel)
{
int onscreen;
switch (sel) {
case SEL_NEXT:
- if (ndents)
+ if (ndents && (cfg.rollover || (cur != ndents - 1)))
move_cursor((cur + 1) % ndents, 0);
break;
case SEL_PREV:
- if (ndents)
+ if (ndents && (cfg.rollover || cur))
move_cursor((cur + ndents - 1) % ndents, 0);
break;
case SEL_PGDN:
@@ -5415,6 +5417,7 @@ static void usage(void)
" -o open files on Enter\n"
" -p file selection file [stdout if '-']\n"
" -r use advcpmv patched cp, mv\n"
+ " -R disable rollover at edges\n"
" -s string filters [default: regex]\n"
" -S du mode\n"
" -t disable dir auto-select\n"
@@ -5561,7 +5564,7 @@ int main(int argc, char *argv[])
bool progress = FALSE;
#endif
- while ((opt = getopt(argc, argv, "HSKiab:cde:Efnop:rstvh")) != -1) {
+ while ((opt = getopt(argc, argv, "HSKiab:cde:Efnop:rRstvh")) != -1) {
switch (opt) {
case 'S':
cfg.blkorder = 1;
@@ -5623,6 +5626,9 @@ int main(int argc, char *argv[])
progress = TRUE;
#endif
break;
+ case 'R':
+ cfg.rollover = 0;
+ break;
case 's':
cfg.filter_re = 0;
filterfn = &visible_str;