commit 3490a959be3f1552f3e8dabb95151cf998fe5d34
parent c611720cba020c421943c6b6aa1dd7c8e76c09eb
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date: Sat, 16 Oct 2021 22:47:21 +0530
make var O_FILEINFO to show file info on hover
Diffstat:
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
@@ -27,6 +27,7 @@ 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
@@ -121,6 +122,10 @@ ifeq ($(strip $(O_MATCHFLTR)),1)
CPPFLAGS += -DMATCHFLTR
endif
+ifeq ($(strip $(O_FILEINFO)),1)
+ CPPFLAGS += -DFILEINFO
+endif
+
ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1)
CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw)
LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw)
diff --git a/src/nnn.c b/src/nnn.c
@@ -847,6 +847,7 @@ static void move_cursor(int target, int ignore_scrolloff);
static char *load_input(int fd, const char *path);
static int set_sort_flags(int r);
static void statusbar(char *path);
+static bool get_output(char *file, char *arg1, char *arg2, int fdout, bool multi, bool page);
#ifndef NOFIFO
static void notify_fifo(bool force);
#endif
@@ -3156,6 +3157,10 @@ static void showfilterinfo(void)
((fnstrstr == &strcasestr) ? "ic" : "noic"));
clearinfoln();
+#ifdef FILEINFO
+ if (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);
}
@@ -6167,9 +6172,15 @@ static void statusbar(char *path)
} else
ptr = "\b";
- tolastln();
attron(COLOR_PAIR(cfg.curctx + 1));
+#ifdef FILEINFO
+ if (get_output("file", "-b", pdents[cur].name, -1, FALSE, FALSE))
+ mvaddstr(xlines - 2, 2, g_buf);
+#endif
+
+ tolastln();
+
printw("%d/%s ", cur + 1, xitoa(ndents));
if (g_state.selmode || nselected) {
@@ -6215,6 +6226,7 @@ static void statusbar(char *path)
}
#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 */
@@ -6226,6 +6238,7 @@ static void statusbar(char *path)
g_buf[i] = '\0';
addstr(g_buf);
}
+#endif
} else {
addstr(coolsize(pent->size));
addch(' ');