Makefile | 5 ----- misc/auto-completion/bash/nnn-completion.bash | 1 + misc/auto-completion/fish/nnn.fish | 1 + misc/auto-completion/zsh/_nnn | 1 + nnn.1 | 3 +++ src/nnn.c | 45 +++++++++++++++++++++++---------------------- diff --git a/Makefile b/Makefile index 7bd84f6901349863f06ef91ee37c616a3f8a5fdf..c6edbfa39cc0ea65e04860cc931d2fee745e52fa 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,6 @@ O_NOSSN := 0 # disable session support O_NOUG := 0 # disable user, group name in status bar O_NOX11 := 0 # disable X11 integration O_MATCHFLTR := 0 # allow filters without matches -O_FILEINFO := 0 # show file informaiton in info line # User patches O_GITSTATUS := 0 # add git status to detail view @@ -120,10 +119,6 @@ endif ifeq ($(strip $(O_MATCHFLTR)),1) CPPFLAGS += -DMATCHFLTR -endif - -ifeq ($(strip $(O_FILEINFO)),1) - CPPFLAGS += -DFILEINFO endif ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1) diff --git a/misc/auto-completion/bash/nnn-completion.bash b/misc/auto-completion/bash/nnn-completion.bash index 6146761cdd348c8f35fb24a14f2dd1bce1903393..e397bf6b7d95738eca7f9f9b9a4d1709c23be56f 100644 --- a/misc/auto-completion/bash/nnn-completion.bash +++ b/misc/auto-completion/bash/nnn-completion.bash @@ -24,6 +24,7 @@ -E -f -g -H + -i -J -K -l diff --git a/misc/auto-completion/fish/nnn.fish b/misc/auto-completion/fish/nnn.fish index 4c75388cdc14db317348d813c4356edf38de2996..4d4ff695c9639fea89200ae8c23858ace99f5c34 100644 --- a/misc/auto-completion/fish/nnn.fish +++ b/misc/auto-completion/fish/nnn.fish @@ -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 g -d 'regex filters' 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 K -d 'detect key collision' complete -c nnn -s l -r -d 'lines to move per scroll' diff --git a/misc/auto-completion/zsh/_nnn b/misc/auto-completion/zsh/_nnn index dd8540a640cf2fb12b4e9db2893c491f30262296..72a0e8b4fa2dc8e2d420d6bdce46f1194bcae2d1 100644 --- a/misc/auto-completion/zsh/_nnn +++ b/misc/auto-completion/zsh/_nnn @@ -21,6 +21,7 @@ '(-E)-E[use EDITOR for undetached edits]' '(-f)-f[use readline history file]' '(-g)-g[regex filters]' '(-H)-H[show hidden files]' + '(-i)-i[show file info on hover]' '(-J)-J[no auto-proceed on select]' '(-K)-K[detect key collision]' '(-l)-l[lines to move per scroll]:val' diff --git a/nnn.1 b/nnn.1 index 9432fa04f16a2f05ad80815f4bfb4357156b3629..e2cc072cd8afb60bf7397194852b6dbbe0017051 100644 --- a/nnn.1 +++ b/nnn.1 @@ -84,6 +84,9 @@ .Pp .Fl H show hidden files .Pp +.Fl i + show file information in info bar on hover +.Pp .Fl J disable auto-proceed on select .Pp diff --git a/src/nnn.c b/src/nnn.c index b32125a5875a5a531473e99f03c9b3a07fa660d7..a79387beafdbdc0f477e4ad7588cfacb8a359078 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -329,12 +329,12 @@ uint_t reserved1 : 1; /* The following settings are global */ uint_t curctx : 3; /* Current context number */ 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 autoselect : 1; /* Auto-select dir in type-to-nav mode */ uint_t cursormode : 1; /* Move hardware cursor with selection */ 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 x11 : 1; /* Copy to system clipboard, show notis, xterm title */ uint_t timetype : 2; /* Time sort type (0: access, 1: change, 2: modification) */ @@ -409,12 +409,12 @@ 0, /* version */ 0, /* reserved1 */ 0, /* curctx */ 0, /* prefersel */ - 0, /* reserved2 */ + 0, /* fileinfo */ 0, /* nonavopen */ 1, /* autoselect */ 0, /* cursormode */ 0, /* useeditor */ - 0, /* reserved3 */ + 0, /* reserved2 */ 0, /* regex */ 0, /* x11 */ 2, /* timetype (T_MOD) */ @@ -3153,10 +3153,9 @@ snprintf(info + i, REGEX_MAX - i - 1, " %s [/], %s [:]", (cfg.regex ? "reg" : "str"), ((fnstrstr == &strcasestr) ? "ic" : "noic")); -#ifdef FILEINFO - if (ndents && get_output("file", "-b", pdents[cur].name, -1, FALSE, FALSE)) + if (cfg.fileinfo && ndents && get_output("file", "-b", pdents[cur].name, -1, FALSE, FALSE)) mvaddstr(xlines - 2, 2, g_buf); -#endif + mvaddstr(xlines - 2, xcols - xstrlen(info), info); } @@ -6169,10 +6168,8 @@ ptr = "\b"; attron(COLOR_PAIR(cfg.curctx + 1)); -#ifdef FILEINFO - if (get_output("file", "-b", pdents[cur].name, -1, FALSE, FALSE)) + if (cfg.fileinfo && get_output("file", "-b", pdents[cur].name, -1, FALSE, FALSE)) mvaddstr(xlines - 2, 2, g_buf); -#endif tolastln(); @@ -6221,19 +6218,19 @@ addch(' '); } #endif if (S_ISLNK(pent->mode)) { -#ifndef FILEINFO - i = readlink(pent->name, g_buf, PATH_MAX); - addstr(coolsize(i >= 0 ? i : pent->size)); /* Show symlink size */ - if (i > 1) { /* Show symlink target */ - int y; + if (!cfg.fileinfo) { + i = readlink(pent->name, g_buf, PATH_MAX); + addstr(coolsize(i >= 0 ? i : pent->size)); /* Show symlink size */ + if (i > 1) { /* Show symlink target */ + int y; - addstr(" ->"); - getyx(stdscr, len, y); - i = MIN(i, xcols - y); - g_buf[i] = '\0'; - addstr(g_buf); + addstr(" ->"); + getyx(stdscr, len, y); + i = MIN(i, xcols - y); + g_buf[i] = '\0'; + addstr(g_buf); + } } -#endif } else { addstr(coolsize(pent->size)); addch(' '); @@ -8039,6 +8036,7 @@ " -F val fifo mode [0:preview 1:explore]\n" #endif " -g regex filters\n" " -H show hidden files\n" + " -i show file info on hover\n" " -J no auto-proceed on select\n" " -K detect key collision\n" " -l val set scroll lines\n" @@ -8222,7 +8220,7 @@ #endif while ((opt = (env_opts_id > 0 ? 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) { #ifndef NOFIFO case 'a': @@ -8275,6 +8273,9 @@ filterfn = &visible_re; break; case 'H': cfg.showhidden = 1; + break; + case 'i': + cfg.fileinfo = 1; break; case 'J': g_state.stayonsel = 1;