misc/auto-completion/bash/nnn-completion.bash | 1 + misc/auto-completion/fish/nnn.fish | 1 + misc/auto-completion/zsh/_nnn | 1 + nnn.1 | 4 ++++ src/nnn.c | 18 +++++++++++++----- diff --git a/misc/auto-completion/bash/nnn-completion.bash b/misc/auto-completion/bash/nnn-completion.bash index 820e1c7c1d4fde5cc4afc7ed35bbc17095bce272..69c2047fe2ff5403e31979bc42a6bd88f35f509e 100644 --- a/misc/auto-completion/bash/nnn-completion.bash +++ b/misc/auto-completion/bash/nnn-completion.bash @@ -16,6 +16,7 @@ -a -A -b -c + -C -d -e -E diff --git a/misc/auto-completion/fish/nnn.fish b/misc/auto-completion/fish/nnn.fish index 9939a5c6ea86b69d976d5b78c48ebae4748deadb..9bc671d2dba4942ab8c13b4eeb39589eab8be8fc 100644 --- a/misc/auto-completion/fish/nnn.fish +++ b/misc/auto-completion/fish/nnn.fish @@ -15,6 +15,7 @@ complete -c nnn -s a -d 'auto-create NNN_FIFO' complete -c nnn -s A -d 'disable dir auto-select' complete -c nnn -s b -r -d 'bookmark key to open' -x -a '(echo $NNN_BMS | awk -F: -v RS=\; \'{print $1"\t"$2}\')' complete -c nnn -s c -d 'cli-only opener' +complete -c nnn -s C -d 'hardware cursor mode' complete -c nnn -s d -d 'start in detail mode' complete -c nnn -s e -d 'open text files in $VISUAL/$EDITOR/vi' complete -c nnn -s E -d 'use EDITOR for undetached edits' diff --git a/misc/auto-completion/zsh/_nnn b/misc/auto-completion/zsh/_nnn index 4504155d007b2acfc78ec98da5ebc5b1817d518b..75a19e2c2054a0bf6d30a341e6454dc109dfce2f 100644 --- a/misc/auto-completion/zsh/_nnn +++ b/misc/auto-completion/zsh/_nnn @@ -13,6 +13,7 @@ '(-a)-a[auto-create NNN_FIFO]' '(-A)-A[disable dir auto-select]' '(-b)-b[bookmark key to open]:key char' '(-c)-c[cli-only opener]' + '(-C)-C[hardware cursor mode]' '(-d)-d[start in detail mode]' '(-e)-e[open text files in $VISUAL/$EDITOR/vi]' '(-E)-E[use EDITOR for undetached edits]' diff --git a/nnn.1 b/nnn.1 index 7950b93cafe85a4327176d6e165f9ae6b4899161..96492b052c891c44432e9753779923f5ad475f4c 100644 --- a/nnn.1 +++ b/nnn.1 @@ -10,6 +10,7 @@ .Op Ar -a .Op Ar -A .Op Ar -b key .Op Ar -c +.Op Ar -C .Op Ar -d .Op Ar -e .Op Ar -E @@ -67,6 +68,9 @@ specify bookmark key to open .Pp .Fl c indicates that the opener is a cli-only opener (overrides -e) +.Pp +.Fl C + place hardware cursor on hovered entry .Pp .Fl d detail mode diff --git a/src/nnn.c b/src/nnn.c index 987844d585437038ed7a0d5a5d947dcb5619dab7..685e6e9ab6c9dbb1bf4dba2cbca9713f06a1e81b 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -266,9 +266,9 @@ uint curctx : 3; /* Current context number */ uint reserved2 : 2; uint nonavopen : 1; /* Open file on right arrow or `l` */ uint autoselect : 1; /* Auto-select dir in type-to-nav mode */ - uint reserved3 : 1; + uint cursormode : 1; /* Move hardware cursor with selection */ uint useeditor : 1; /* Use VISUAL to open text files */ - uint reserved4 : 3; + uint reserved3 : 3; uint regex : 1; /* Use regex filters */ uint x11 : 1; /* Copy to system clipboard and show notis */ uint timetype : 2; /* Time sort type (0: access, 1: change, 2: modification) */ @@ -337,9 +337,9 @@ 0, /* curctx */ 0, /* reserved2 */ 0, /* nonavopen */ 1, /* autoselect */ - 0, /* reserved3 */ + 0, /* cursormode */ 0, /* useeditor */ - 0, /* reserved4 */ + 0, /* reserved3 */ 0, /* regex */ 0, /* x11 */ 2, /* timetype (T_MOD) */ @@ -681,6 +681,7 @@ #endif /* Function macros */ #define tolastln() move(xlines - 1, 0) +#define tocursor() move(cur + 2, 0) #define exitcurses() endwin() #define printwarn(presel) printwait(strerror(errno), presel) #define istopdir(path) ((path)[1] == '\0' && (path)[0] == '/') @@ -5133,6 +5134,9 @@ addch('\n'); } attroff(COLOR_PAIR(cfg.curctx + 1)); + + if (cfg.cursormode) + tocursor(); } static int adjust_cols(int ncols) @@ -6821,6 +6825,7 @@ #endif " -A no dir auto-select\n" " -b key open bookmark key (trumps -s/S)\n" " -c cli-only NNN_OPENER (trumps -e)\n" + " -C place HW cursor on hovered\n" " -d detail mode\n" " -e text in $VISUAL/$EDITOR/vi\n" " -E use EDITOR for undetached edits\n" @@ -6992,7 +6997,7 @@ #endif while ((opt = (env_opts_id > 0 ? env_opts[--env_opts_id] - : getopt(argc, argv, "aAb:cdeEfFgHKl:nop:P:QrRs:St:T:Vxh"))) != -1) { + : getopt(argc, argv, "aAb:cCdeEfFgHKl:nop:P:QrRs:St:T:Vxh"))) != -1) { switch (opt) { #ifndef NOFIFO case 'a': @@ -7030,6 +7035,9 @@ break; case 'g': cfg.regex = 1; filterfn = &visible_re; + break; + case 'C': + cfg.cursormode = 1; break; case 'H': cfg.showhidden = 1;