mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Resurrect current/sel prompt
This commit is contained in:
parent
2dccb94f3f
commit
93ca773c59
|
@ -39,6 +39,7 @@ _nnn ()
|
||||||
-S
|
-S
|
||||||
-t
|
-t
|
||||||
-T
|
-T
|
||||||
|
-u
|
||||||
-U
|
-U
|
||||||
-V
|
-V
|
||||||
-w
|
-w
|
||||||
|
|
|
@ -38,6 +38,7 @@ complete -c nnn -s s -r -d 'load session by name' -x -a '@\t"last session" (ls $
|
||||||
complete -c nnn -s S -d 'persistent session'
|
complete -c nnn -s S -d 'persistent session'
|
||||||
complete -c nnn -s t -r -d 'timeout in seconds to lock'
|
complete -c nnn -s t -r -d 'timeout in seconds to lock'
|
||||||
complete -c nnn -s T -r -d 'a d e r s t v'
|
complete -c nnn -s T -r -d 'a d e r s t v'
|
||||||
|
complete -c nnn -s u -d 'use selection (no prompt)'
|
||||||
complete -c nnn -s U -d 'show user and group'
|
complete -c nnn -s U -d 'show user and group'
|
||||||
complete -c nnn -s V -d 'show program version and exit'
|
complete -c nnn -s V -d 'show program version and exit'
|
||||||
complete -c nnn -s w -d 'hardware cursor mode'
|
complete -c nnn -s w -d 'hardware cursor mode'
|
||||||
|
|
|
@ -36,6 +36,7 @@ args=(
|
||||||
'(-S)-S[persistent session]'
|
'(-S)-S[persistent session]'
|
||||||
'(-t)-t[timeout to lock]:seconds'
|
'(-t)-t[timeout to lock]:seconds'
|
||||||
'(-T)-T[a d e r s t v]:key'
|
'(-T)-T[a d e r s t v]:key'
|
||||||
|
'(-u)-u[use selection (no prompt)]'
|
||||||
'(-U)-U[show user and group]'
|
'(-U)-U[show user and group]'
|
||||||
'(-V)-V[show program version and exit]'
|
'(-V)-V[show program version and exit]'
|
||||||
'(-w)-C[hardware cursor mode]'
|
'(-w)-C[hardware cursor mode]'
|
||||||
|
|
4
nnn.1
4
nnn.1
|
@ -32,6 +32,7 @@
|
||||||
.Op Ar -S
|
.Op Ar -S
|
||||||
.Op Ar -t secs
|
.Op Ar -t secs
|
||||||
.Op Ar -T key
|
.Op Ar -T key
|
||||||
|
.Op Ar -u
|
||||||
.Op Ar -U
|
.Op Ar -U
|
||||||
.Op Ar -V
|
.Op Ar -V
|
||||||
.Op Ar -w
|
.Op Ar -w
|
||||||
|
@ -144,6 +145,9 @@ supports the following options:
|
||||||
sort order
|
sort order
|
||||||
keys: 'a'u / 'd'u / 'e'xtension / 'r'everse / 's'ize / 't'ime / 'v'ersion
|
keys: 'a'u / 'd'u / 'e'xtension / 'r'everse / 's'ize / 't'ime / 'v'ersion
|
||||||
.Pp
|
.Pp
|
||||||
|
.Fl u
|
||||||
|
use selection if available, don't prompt to choose between selection and hovered entry
|
||||||
|
.Pp
|
||||||
.Fl U
|
.Fl U
|
||||||
show user and group names in status bar
|
show user and group names in status bar
|
||||||
.Pp
|
.Pp
|
||||||
|
|
29
src/nnn.c
29
src/nnn.c
|
@ -295,7 +295,8 @@ typedef struct {
|
||||||
uint_t reserved1 : 1;
|
uint_t reserved1 : 1;
|
||||||
/* The following settings are global */
|
/* The following settings are global */
|
||||||
uint_t curctx : 3; /* Current context number */
|
uint_t curctx : 3; /* Current context number */
|
||||||
uint_t reserved2 : 2;
|
uint_t prefersel : 1; /* Prefer selection over current, if exists */
|
||||||
|
uint_t reserved2 : 1;
|
||||||
uint_t nonavopen : 1; /* Open file on right arrow or `l` */
|
uint_t nonavopen : 1; /* Open file on right arrow or `l` */
|
||||||
uint_t autoselect : 1; /* Auto-select dir in type-to-nav mode */
|
uint_t autoselect : 1; /* Auto-select dir in type-to-nav mode */
|
||||||
uint_t cursormode : 1; /* Move hardware cursor with selection */
|
uint_t cursormode : 1; /* Move hardware cursor with selection */
|
||||||
|
@ -372,6 +373,7 @@ static settings cfg = {
|
||||||
0, /* version */
|
0, /* version */
|
||||||
0, /* reserved1 */
|
0, /* reserved1 */
|
||||||
0, /* curctx */
|
0, /* curctx */
|
||||||
|
0, /* prefersel */
|
||||||
0, /* reserved2 */
|
0, /* reserved2 */
|
||||||
0, /* nonavopen */
|
0, /* nonavopen */
|
||||||
1, /* autoselect */
|
1, /* autoselect */
|
||||||
|
@ -524,7 +526,7 @@ static char * const utils[] = {
|
||||||
#define MSG_FAILED 5
|
#define MSG_FAILED 5
|
||||||
#define MSG_SSN_NAME 6
|
#define MSG_SSN_NAME 6
|
||||||
#define MSG_CP_MV_AS 7
|
#define MSG_CP_MV_AS 7
|
||||||
#define MSG_NOCHNAGE 8
|
#define MSG_CUR_SEL_OPTS 8
|
||||||
#define MSG_FORCE_RM 9
|
#define MSG_FORCE_RM 9
|
||||||
#define MSG_LIMIT 10
|
#define MSG_LIMIT 10
|
||||||
#define MSG_NEW_OPTS 11
|
#define MSG_NEW_OPTS 11
|
||||||
|
@ -558,8 +560,9 @@ static char * const utils[] = {
|
||||||
#define MSG_FIRST 39
|
#define MSG_FIRST 39
|
||||||
#define MSG_RM_TMP 40
|
#define MSG_RM_TMP 40
|
||||||
#define MSG_INVALID_KEY 41
|
#define MSG_INVALID_KEY 41
|
||||||
|
#define MSG_NOCHANGE 42
|
||||||
#ifndef DIR_LIMITED_SELECTION
|
#ifndef DIR_LIMITED_SELECTION
|
||||||
#define MSG_DIR_CHANGED 42 /* Must be the last entry */
|
#define MSG_DIR_CHANGED 43 /* Must be the last entry */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char * const messages[] = {
|
static const char * const messages[] = {
|
||||||
|
@ -571,7 +574,7 @@ static const char * const messages[] = {
|
||||||
"failed!",
|
"failed!",
|
||||||
"session name: ",
|
"session name: ",
|
||||||
"'c'p / 'm'v as?",
|
"'c'p / 'm'v as?",
|
||||||
"unchanged",
|
"'c'urrent / 's'el?",
|
||||||
"rm -rf %s file%s? [Esc cancels]",
|
"rm -rf %s file%s? [Esc cancels]",
|
||||||
"limit exceeded",
|
"limit exceeded",
|
||||||
"'f'ile / 'd'ir / 's'ym / 'h'ard?",
|
"'f'ile / 'd'ir / 's'ym / 'h'ard?",
|
||||||
|
@ -605,6 +608,7 @@ static const char * const messages[] = {
|
||||||
"first file (\')/char?",
|
"first file (\')/char?",
|
||||||
"remove tmp file?",
|
"remove tmp file?",
|
||||||
"invalid key",
|
"invalid key",
|
||||||
|
"unchanged",
|
||||||
#ifndef DIR_LIMITED_SELECTION
|
#ifndef DIR_LIMITED_SELECTION
|
||||||
"dir changed, range sel off", /* Must be the last entry */
|
"dir changed, range sel off", /* Must be the last entry */
|
||||||
#endif
|
#endif
|
||||||
|
@ -1222,6 +1226,15 @@ static int get_input(const char *prompt)
|
||||||
|
|
||||||
static int get_cur_or_sel(void)
|
static int get_cur_or_sel(void)
|
||||||
{
|
{
|
||||||
|
if (selbufpos && ndents) {
|
||||||
|
if (cfg.prefersel)
|
||||||
|
return 's';
|
||||||
|
|
||||||
|
int choice = get_input(messages[MSG_CUR_SEL_OPTS]);
|
||||||
|
|
||||||
|
return ((choice == 'c' || choice == 's') ? choice : 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (selbufpos)
|
if (selbufpos)
|
||||||
return 's';
|
return 's';
|
||||||
|
|
||||||
|
@ -5578,7 +5591,7 @@ static bool set_time_type(int *presel)
|
||||||
|
|
||||||
ret = TRUE;
|
ret = TRUE;
|
||||||
} else
|
} else
|
||||||
r = MSG_NOCHNAGE;
|
r = MSG_NOCHANGE;
|
||||||
} else
|
} else
|
||||||
r = MSG_INVALID_KEY;
|
r = MSG_INVALID_KEY;
|
||||||
|
|
||||||
|
@ -7428,6 +7441,7 @@ static void usage(void)
|
||||||
#endif
|
#endif
|
||||||
" -t secs timeout to lock\n"
|
" -t secs timeout to lock\n"
|
||||||
" -T key sort order [a/d/e/r/s/t/v]\n"
|
" -T key sort order [a/d/e/r/s/t/v]\n"
|
||||||
|
" -u use selection (no prompt)\n"
|
||||||
#ifndef NOUG
|
#ifndef NOUG
|
||||||
" -U show user and group\n"
|
" -U show user and group\n"
|
||||||
#endif
|
#endif
|
||||||
|
@ -7584,7 +7598,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, "aAb:cCdDeEfFgHJKl:nop:P:QrRs:St:T:UVwxh"))) != -1) {
|
: getopt(argc, argv, "aAb:cCdDeEfFgHJKl:nop:P:QrRs:St:T:uUVwxh"))) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
#ifndef NOFIFO
|
#ifndef NOFIFO
|
||||||
case 'a':
|
case 'a':
|
||||||
|
@ -7700,6 +7714,9 @@ int main(int argc, char *argv[])
|
||||||
if (env_opts_id < 0)
|
if (env_opts_id < 0)
|
||||||
sort = (uchar_t)optarg[0];
|
sort = (uchar_t)optarg[0];
|
||||||
break;
|
break;
|
||||||
|
case 'u':
|
||||||
|
cfg.prefersel = 1;
|
||||||
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
g_state.uidgid = 1;
|
g_state.uidgid = 1;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue