make var O_FILEINFO to show file info on hover

This commit is contained in:
Arun Prakash Jana 2021-10-16 22:47:21 +05:30
parent c611720cba
commit 3490a959be
No known key found for this signature in database
GPG Key ID: A75979F35C080412
2 changed files with 19 additions and 1 deletions

View File

@ -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)

View File

@ -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(' ');