aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-05-10 11:21:37 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-05-10 11:22:02 +0530
commit14beb0746f07f94f52c5b628b046d3c9f2add9c6 (patch)
treeb13f2a9a8de065ffe5577766097f645ad8ea2f68 /src
parent609561494f106822b3deb5ff2ef184d17703f7df (diff)
downloadnnn-14beb0746f07f94f52c5b628b046d3c9f2add9c6.tar.gz
Fix #564: Option -l: number of lines to move on mouse scroll
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 081fac0..3cf8977 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -324,7 +324,7 @@ static settings cfg = {
static context g_ctx[CTX_MAX] __attribute__ ((aligned));
-static int ndents, cur, last, curscroll, last_curscroll, total_dents = ENTRY_INCR;
+static int ndents, cur, last, curscroll, last_curscroll, total_dents = ENTRY_INCR, scroll_lines = 1;
static int nselected;
#ifndef NOFIFO
static int fifofd = -1;
@@ -5391,14 +5391,14 @@ nochange:
#if NCURSES_MOUSE_VERSION > 1
/* Scroll up */
if (event.bstate == BUTTON4_PRESSED && ndents && (cfg.rollover || cur)) {
- move_cursor((cur + ndents - 1) % ndents, 0);
+ move_cursor((cur + ndents - scroll_lines) % ndents, 0);
break;
}
/* Scroll down */
if (event.bstate == BUTTON5_PRESSED && ndents
&& (cfg.rollover || (cur != ndents - 1))) {
- move_cursor((cur + 1) % ndents, 0);
+ move_cursor((cur + scroll_lines) % ndents, 0);
break;
}
#endif
@@ -6689,6 +6689,7 @@ static void usage(void)
" -g regex filters [default: string]\n"
" -H show hidden files\n"
" -K detect key collision\n"
+ " -l val set scroll lines\n"
" -n type-to-nav mode\n"
" -o open files only on Enter\n"
" -p file selection file [stdout if '-']\n"
@@ -6854,7 +6855,7 @@ int main(int argc, char *argv[])
while ((opt = (env_opts_id > 0
? env_opts[--env_opts_id]
- : getopt(argc, argv, "Ab:cdeEfFgHKnop:QrRs:St:T:Vxh"))) != -1) {
+ : getopt(argc, argv, "Ab:cdeEfFgHKl:nop:QrRs:St:T:Vxh"))) != -1) {
switch (opt) {
case 'A':
cfg.autoselect = 0;
@@ -6893,6 +6894,10 @@ int main(int argc, char *argv[])
case 'K':
check_key_collision();
return EXIT_SUCCESS;
+ case 'l':
+ if (env_opts_id < 0)
+ scroll_lines = atoi(optarg);
+ break;
case 'n':
cfg.filtermode = 1;
break;