mirror of
https://github.com/jarun/nnn.git
synced 2024-12-01 02:49:44 +00:00
Fix #564: Option -l: number of lines to move on mouse scroll
This commit is contained in:
parent
609561494f
commit
14beb0746f
|
@ -23,6 +23,7 @@ _nnn ()
|
||||||
-g
|
-g
|
||||||
-H
|
-H
|
||||||
-K
|
-K
|
||||||
|
-l
|
||||||
-n
|
-n
|
||||||
-o
|
-o
|
||||||
-p
|
-p
|
||||||
|
@ -40,6 +41,8 @@ _nnn ()
|
||||||
if [[ $prev == -b ]]; then
|
if [[ $prev == -b ]]; then
|
||||||
local bookmarks=$(echo $NNN_BMS | awk -F: -v RS=\; '{print $1}')
|
local bookmarks=$(echo $NNN_BMS | awk -F: -v RS=\; '{print $1}')
|
||||||
COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
|
COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
|
||||||
|
elif [[ $prev == -l ]]; then
|
||||||
|
return 1
|
||||||
elif [[ $prev == -p ]]; then
|
elif [[ $prev == -p ]]; then
|
||||||
COMPREPLY=( $(compgen -f -d -- "$cur") )
|
COMPREPLY=( $(compgen -f -d -- "$cur") )
|
||||||
elif [[ $prev == -s ]]; then
|
elif [[ $prev == -s ]]; then
|
||||||
|
|
|
@ -22,6 +22,7 @@ complete -c nnn -s F -d 'show fortune'
|
||||||
complete -c nnn -s g -d 'regex filters'
|
complete -c nnn -s g -d 'regex filters'
|
||||||
complete -c nnn -s H -d 'show hidden files'
|
complete -c nnn -s H -d 'show hidden files'
|
||||||
complete -c nnn -s K -d 'detect key collision'
|
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 n -d 'start in type-to-nav mode'
|
||||||
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'
|
||||||
|
|
|
@ -20,6 +20,7 @@ args=(
|
||||||
'(-g)-g[regex filters]'
|
'(-g)-g[regex filters]'
|
||||||
'(-H)-H[show hidden files]'
|
'(-H)-H[show hidden files]'
|
||||||
'(-K)-K[detect key collision]'
|
'(-K)-K[detect key collision]'
|
||||||
|
'(-l)-l[lines to move per scroll]:val'
|
||||||
'(-n)-n[start in type-to-nav mode]'
|
'(-n)-n[start in type-to-nav mode]'
|
||||||
'(-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'
|
||||||
|
|
4
nnn.1
4
nnn.1
|
@ -17,6 +17,7 @@
|
||||||
.Op Ar -g
|
.Op Ar -g
|
||||||
.Op Ar -H
|
.Op Ar -H
|
||||||
.Op Ar -K
|
.Op Ar -K
|
||||||
|
.Op Ar -l
|
||||||
.Op Ar -n
|
.Op Ar -n
|
||||||
.Op Ar -p file
|
.Op Ar -p file
|
||||||
.Op Ar -Q
|
.Op Ar -Q
|
||||||
|
@ -86,6 +87,9 @@ supports the following options:
|
||||||
.Fl K
|
.Fl K
|
||||||
test for keybind collision
|
test for keybind collision
|
||||||
.Pp
|
.Pp
|
||||||
|
.Fl "l val"
|
||||||
|
number of lines to move per mouse wheel scroll
|
||||||
|
.Pp
|
||||||
.Fl n
|
.Fl n
|
||||||
start in type-to-nav mode
|
start in type-to-nav mode
|
||||||
.Pp
|
.Pp
|
||||||
|
|
13
src/nnn.c
13
src/nnn.c
|
@ -324,7 +324,7 @@ static settings cfg = {
|
||||||
|
|
||||||
static context g_ctx[CTX_MAX] __attribute__ ((aligned));
|
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;
|
static int nselected;
|
||||||
#ifndef NOFIFO
|
#ifndef NOFIFO
|
||||||
static int fifofd = -1;
|
static int fifofd = -1;
|
||||||
|
@ -5391,14 +5391,14 @@ nochange:
|
||||||
#if NCURSES_MOUSE_VERSION > 1
|
#if NCURSES_MOUSE_VERSION > 1
|
||||||
/* Scroll up */
|
/* Scroll up */
|
||||||
if (event.bstate == BUTTON4_PRESSED && ndents && (cfg.rollover || cur)) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scroll down */
|
/* Scroll down */
|
||||||
if (event.bstate == BUTTON5_PRESSED && ndents
|
if (event.bstate == BUTTON5_PRESSED && ndents
|
||||||
&& (cfg.rollover || (cur != ndents - 1))) {
|
&& (cfg.rollover || (cur != ndents - 1))) {
|
||||||
move_cursor((cur + 1) % ndents, 0);
|
move_cursor((cur + scroll_lines) % ndents, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -6689,6 +6689,7 @@ static void usage(void)
|
||||||
" -g regex filters [default: string]\n"
|
" -g regex filters [default: string]\n"
|
||||||
" -H show hidden files\n"
|
" -H show hidden files\n"
|
||||||
" -K detect key collision\n"
|
" -K detect key collision\n"
|
||||||
|
" -l val set scroll lines\n"
|
||||||
" -n type-to-nav mode\n"
|
" -n type-to-nav mode\n"
|
||||||
" -o open files only on Enter\n"
|
" -o open files only on Enter\n"
|
||||||
" -p file selection file [stdout if '-']\n"
|
" -p file selection file [stdout if '-']\n"
|
||||||
|
@ -6854,7 +6855,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
while ((opt = (env_opts_id > 0
|
while ((opt = (env_opts_id > 0
|
||||||
? env_opts[--env_opts_id]
|
? 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) {
|
switch (opt) {
|
||||||
case 'A':
|
case 'A':
|
||||||
cfg.autoselect = 0;
|
cfg.autoselect = 0;
|
||||||
|
@ -6893,6 +6894,10 @@ int main(int argc, char *argv[])
|
||||||
case 'K':
|
case 'K':
|
||||||
check_key_collision();
|
check_key_collision();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
case 'l':
|
||||||
|
if (env_opts_id < 0)
|
||||||
|
scroll_lines = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
cfg.filtermode = 1;
|
cfg.filtermode = 1;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue