mirror of
https://github.com/jarun/nnn.git
synced 2024-11-17 08:32:36 +00:00
Add option -i to show file information on hover
This commit is contained in:
parent
9c36f0df34
commit
a06ff83c22
5
Makefile
5
Makefile
|
@ -27,7 +27,6 @@ O_NOSSN := 0 # disable session support
|
||||||
O_NOUG := 0 # disable user, group name in status bar
|
O_NOUG := 0 # disable user, group name in status bar
|
||||||
O_NOX11 := 0 # disable X11 integration
|
O_NOX11 := 0 # disable X11 integration
|
||||||
O_MATCHFLTR := 0 # allow filters without matches
|
O_MATCHFLTR := 0 # allow filters without matches
|
||||||
O_FILEINFO := 0 # show file informaiton in info line
|
|
||||||
|
|
||||||
# User patches
|
# User patches
|
||||||
O_GITSTATUS := 0 # add git status to detail view
|
O_GITSTATUS := 0 # add git status to detail view
|
||||||
|
@ -122,10 +121,6 @@ ifeq ($(strip $(O_MATCHFLTR)),1)
|
||||||
CPPFLAGS += -DMATCHFLTR
|
CPPFLAGS += -DMATCHFLTR
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(strip $(O_FILEINFO)),1)
|
|
||||||
CPPFLAGS += -DFILEINFO
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
|
ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
|
||||||
CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
|
CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
|
||||||
LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
|
LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
|
||||||
|
|
|
@ -24,6 +24,7 @@ _nnn ()
|
||||||
-f
|
-f
|
||||||
-g
|
-g
|
||||||
-H
|
-H
|
||||||
|
-i
|
||||||
-J
|
-J
|
||||||
-K
|
-K
|
||||||
-l
|
-l
|
||||||
|
|
|
@ -23,6 +23,7 @@ complete -c nnn -s E -d 'use EDITOR for undetached edits'
|
||||||
complete -c nnn -s f -d 'use readline history file'
|
complete -c nnn -s f -d 'use readline history file'
|
||||||
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 i -d 'show file info on hover'
|
||||||
complete -c nnn -s J -d 'no auto-proceed on select'
|
complete -c nnn -s J -d 'no auto-proceed on select'
|
||||||
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 l -r -d 'lines to move per scroll'
|
||||||
|
|
|
@ -21,6 +21,7 @@ args=(
|
||||||
'(-f)-f[use readline history file]'
|
'(-f)-f[use readline history file]'
|
||||||
'(-g)-g[regex filters]'
|
'(-g)-g[regex filters]'
|
||||||
'(-H)-H[show hidden files]'
|
'(-H)-H[show hidden files]'
|
||||||
|
'(-i)-i[show file info on hover]'
|
||||||
'(-J)-J[no auto-proceed on select]'
|
'(-J)-J[no auto-proceed on select]'
|
||||||
'(-K)-K[detect key collision]'
|
'(-K)-K[detect key collision]'
|
||||||
'(-l)-l[lines to move per scroll]:val'
|
'(-l)-l[lines to move per scroll]:val'
|
||||||
|
|
3
nnn.1
3
nnn.1
|
@ -84,6 +84,9 @@ supports the following options:
|
||||||
.Fl H
|
.Fl H
|
||||||
show hidden files
|
show hidden files
|
||||||
.Pp
|
.Pp
|
||||||
|
.Fl i
|
||||||
|
show file information in info bar on hover
|
||||||
|
.Pp
|
||||||
.Fl J
|
.Fl J
|
||||||
disable auto-proceed on select
|
disable auto-proceed on select
|
||||||
.Pp
|
.Pp
|
||||||
|
|
27
src/nnn.c
27
src/nnn.c
|
@ -329,12 +329,12 @@ typedef struct {
|
||||||
/* 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 prefersel : 1; /* Prefer selection over current, if exists */
|
uint_t prefersel : 1; /* Prefer selection over current, if exists */
|
||||||
uint_t reserved2 : 1;
|
uint_t fileinfo : 1; /* Show file information on hover */
|
||||||
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 */
|
||||||
uint_t useeditor : 1; /* Use VISUAL to open text files */
|
uint_t useeditor : 1; /* Use VISUAL to open text files */
|
||||||
uint_t reserved3 : 3;
|
uint_t reserved2 : 3;
|
||||||
uint_t regex : 1; /* Use regex filters */
|
uint_t regex : 1; /* Use regex filters */
|
||||||
uint_t x11 : 1; /* Copy to system clipboard, show notis, xterm title */
|
uint_t x11 : 1; /* Copy to system clipboard, show notis, xterm title */
|
||||||
uint_t timetype : 2; /* Time sort type (0: access, 1: change, 2: modification) */
|
uint_t timetype : 2; /* Time sort type (0: access, 1: change, 2: modification) */
|
||||||
|
@ -409,12 +409,12 @@ static settings cfg = {
|
||||||
0, /* reserved1 */
|
0, /* reserved1 */
|
||||||
0, /* curctx */
|
0, /* curctx */
|
||||||
0, /* prefersel */
|
0, /* prefersel */
|
||||||
0, /* reserved2 */
|
0, /* fileinfo */
|
||||||
0, /* nonavopen */
|
0, /* nonavopen */
|
||||||
1, /* autoselect */
|
1, /* autoselect */
|
||||||
0, /* cursormode */
|
0, /* cursormode */
|
||||||
0, /* useeditor */
|
0, /* useeditor */
|
||||||
0, /* reserved3 */
|
0, /* reserved2 */
|
||||||
0, /* regex */
|
0, /* regex */
|
||||||
0, /* x11 */
|
0, /* x11 */
|
||||||
2, /* timetype (T_MOD) */
|
2, /* timetype (T_MOD) */
|
||||||
|
@ -3153,10 +3153,9 @@ static void showfilterinfo(void)
|
||||||
(cfg.regex ? "reg" : "str"),
|
(cfg.regex ? "reg" : "str"),
|
||||||
((fnstrstr == &strcasestr) ? "ic" : "noic"));
|
((fnstrstr == &strcasestr) ? "ic" : "noic"));
|
||||||
|
|
||||||
#ifdef FILEINFO
|
if (cfg.fileinfo && ndents && get_output("file", "-b", pdents[cur].name, -1, FALSE, FALSE))
|
||||||
if (ndents && get_output("file", "-b", pdents[cur].name, -1, FALSE, FALSE))
|
|
||||||
mvaddstr(xlines - 2, 2, g_buf);
|
mvaddstr(xlines - 2, 2, g_buf);
|
||||||
#endif
|
|
||||||
mvaddstr(xlines - 2, xcols - xstrlen(info), info);
|
mvaddstr(xlines - 2, xcols - xstrlen(info), info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6169,10 +6168,8 @@ static void statusbar(char *path)
|
||||||
|
|
||||||
attron(COLOR_PAIR(cfg.curctx + 1));
|
attron(COLOR_PAIR(cfg.curctx + 1));
|
||||||
|
|
||||||
#ifdef FILEINFO
|
if (cfg.fileinfo && get_output("file", "-b", pdents[cur].name, -1, FALSE, FALSE))
|
||||||
if (get_output("file", "-b", pdents[cur].name, -1, FALSE, FALSE))
|
|
||||||
mvaddstr(xlines - 2, 2, g_buf);
|
mvaddstr(xlines - 2, 2, g_buf);
|
||||||
#endif
|
|
||||||
|
|
||||||
tolastln();
|
tolastln();
|
||||||
|
|
||||||
|
@ -6221,7 +6218,7 @@ static void statusbar(char *path)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (S_ISLNK(pent->mode)) {
|
if (S_ISLNK(pent->mode)) {
|
||||||
#ifndef FILEINFO
|
if (!cfg.fileinfo) {
|
||||||
i = readlink(pent->name, g_buf, PATH_MAX);
|
i = readlink(pent->name, g_buf, PATH_MAX);
|
||||||
addstr(coolsize(i >= 0 ? i : pent->size)); /* Show symlink size */
|
addstr(coolsize(i >= 0 ? i : pent->size)); /* Show symlink size */
|
||||||
if (i > 1) { /* Show symlink target */
|
if (i > 1) { /* Show symlink target */
|
||||||
|
@ -6233,7 +6230,7 @@ static void statusbar(char *path)
|
||||||
g_buf[i] = '\0';
|
g_buf[i] = '\0';
|
||||||
addstr(g_buf);
|
addstr(g_buf);
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
} else {
|
} else {
|
||||||
addstr(coolsize(pent->size));
|
addstr(coolsize(pent->size));
|
||||||
addch(' ');
|
addch(' ');
|
||||||
|
@ -8039,6 +8036,7 @@ static void usage(void)
|
||||||
#endif
|
#endif
|
||||||
" -g regex filters\n"
|
" -g regex filters\n"
|
||||||
" -H show hidden files\n"
|
" -H show hidden files\n"
|
||||||
|
" -i show file info on hover\n"
|
||||||
" -J no auto-proceed on select\n"
|
" -J no auto-proceed on select\n"
|
||||||
" -K detect key collision\n"
|
" -K detect key collision\n"
|
||||||
" -l val set scroll lines\n"
|
" -l val set scroll lines\n"
|
||||||
|
@ -8222,7 +8220,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:cCdDeEfF:gHJKl:nop:P:QrRs:St:T:uUVwxh"))) != -1) {
|
: getopt(argc, argv, "aAb:cCdDeEfF:gHiJKl:nop:P:QrRs:St:T:uUVwxh"))) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
#ifndef NOFIFO
|
#ifndef NOFIFO
|
||||||
case 'a':
|
case 'a':
|
||||||
|
@ -8276,6 +8274,9 @@ int main(int argc, char *argv[])
|
||||||
case 'H':
|
case 'H':
|
||||||
cfg.showhidden = 1;
|
cfg.showhidden = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
cfg.fileinfo = 1;
|
||||||
|
break;
|
||||||
case 'J':
|
case 'J':
|
||||||
g_state.stayonsel = 1;
|
g_state.stayonsel = 1;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue