]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix #564: Option -l: number of lines to move on mouse scroll
authorArun Prakash Jana <engineerarun@gmail.com>
Sun, 10 May 2020 05:51:37 +0000 (11:21 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sun, 10 May 2020 05:52:02 +0000 (11:22 +0530)
misc/auto-completion/bash/nnn-completion.bash
misc/auto-completion/fish/nnn.fish
misc/auto-completion/zsh/_nnn
nnn.1
src/nnn.c

index b498b63147c3d2bcfb40da45c301b40f7b483d49..eeb11568f319639eadb45bbf883a9a2e0b8d71cb 100644 (file)
@@ -23,6 +23,7 @@ _nnn ()
         -g
         -H
         -K
+        -l
         -n
         -o
         -p
@@ -40,6 +41,8 @@ _nnn ()
     if [[ $prev == -b ]]; then
         local bookmarks=$(echo $NNN_BMS | awk -F: -v RS=\; '{print $1}')
         COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
+    elif [[ $prev == -l ]]; then
+        return 1
     elif [[ $prev == -p ]]; then
         COMPREPLY=( $(compgen -f -d -- "$cur") )
     elif [[ $prev == -s ]]; then
index 787f87b82572872ea53139d6169fc702bed154fb..65ab0308b05bf56f03acf0a6f508ca42e5a512a2 100644 (file)
@@ -22,6 +22,7 @@ complete -c nnn -s F    -d 'show fortune'
 complete -c nnn -s g    -d 'regex filters'
 complete -c nnn -s H    -d 'show hidden files'
 complete -c nnn -s K    -d 'detect key collision'
+complete -c nnn -s l -r -d 'lines to move per scroll'
 complete -c nnn -s n    -d 'start in type-to-nav mode'
 complete -c nnn -s o    -d 'open files only on Enter'
 complete -c nnn -s p -r -d 'copy selection to file' -a '-\tstdout'
index 0251f3829b0cc5c354c447860f7099d175f7a04b..4b403067d1e8804b805c8418c7e6b798a74471f5 100644 (file)
@@ -20,6 +20,7 @@ args=(
     '(-g)-g[regex filters]'
     '(-H)-H[show hidden files]'
     '(-K)-K[detect key collision]'
+    '(-l)-l[lines to move per scroll]:val'
     '(-n)-n[start in type-to-nav mode]'
     '(-o)-o[open files only on Enter]'
     '(-p)-p[copy selection to file]:file name'
diff --git a/nnn.1 b/nnn.1
index 8d1c4d3aef431a30b5c1f2e8f73b7fd9d9eba7cc..67b1b583e66c95754238b5865347e820bba96416 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -17,6 +17,7 @@
 .Op Ar -g
 .Op Ar -H
 .Op Ar -K
+.Op Ar -l
 .Op Ar -n
 .Op Ar -p file
 .Op Ar -Q
@@ -86,6 +87,9 @@ supports the following options:
 .Fl K
         test for keybind collision
 .Pp
+.Fl "l val"
+        number of lines to move per mouse wheel scroll
+.Pp
 .Fl n
         start in type-to-nav mode
 .Pp
index 081fac022b84461c73043b9e55dd7669f0099cbf..3cf89770962e680ca220608d5856514252bd8fac 100644 (file)
--- 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;