# Authors: Luuk van Baal
diff --git a/src/nnn.c b/src/nnn.c
-index 1028906a..c80314de 100644
+index 508ee915..77d56d63 100644
--- a/src/nnn.c
+++ b/src/nnn.c
-@@ -262,6 +262,25 @@
+@@ -265,6 +265,25 @@
#define FREE 0
#define CAPACITY 1
/* TYPE DEFINITIONS */
typedef unsigned int uint_t;
typedef unsigned char uchar_t;
-@@ -286,6 +305,7 @@ typedef struct entry {
+@@ -289,6 +308,7 @@ typedef struct entry {
uid_t uid; /* 4 bytes */
gid_t gid; /* 4 bytes */
#endif
} *pEntry;
/* Selection marker */
-@@ -342,6 +362,7 @@ typedef struct {
+@@ -345,6 +365,7 @@ typedef struct {
uint_t cliopener : 1; /* All-CLI app opener */
uint_t waitedit : 1; /* For ops that can't be detached, used EDITOR */
uint_t rollover : 1; /* Roll over at edges */
} settings;
/* Non-persistent program-internal states (alphabeical order) */
-@@ -391,7 +412,17 @@ typedef struct {
+@@ -394,7 +415,17 @@ typedef struct {
} session_header_t;
#endif
/* Configuration, contexts */
static settings cfg = {
-@@ -422,6 +453,7 @@ static settings cfg = {
+@@ -425,6 +456,7 @@ static settings cfg = {
0, /* cliopener */
0, /* waitedit */
1, /* rollover */
};
static context g_ctx[CTX_MAX] __attribute__ ((aligned));
-@@ -3839,6 +3871,56 @@ static int get_kv_key(kv *kvarr, char *val, uchar_t max, uchar_t id)
+@@ -3838,6 +3870,56 @@ static int get_kv_key(kv *kvarr, char *val, uchar_t max, uchar_t id)
return -1;
}
static void resetdircolor(int flags)
{
/* Directories are always shown on top, clear the color when moving to first file */
-@@ -4176,6 +4258,10 @@ static void printent(const struct entry *ent, uint_t namecols, bool sel)
+@@ -4182,6 +4264,10 @@ static void printent(const struct entry *ent, uint_t namecols, bool sel)
uchar_t color_pair = get_color_pair_name_ind(ent, &ind, &attrs);
addch((ent->flags & FILE_SELECTED) ? '+' | A_REVERSE | A_BOLD : ' ');
if (g_state.oldcolor)
-@@ -5617,6 +5703,11 @@ static int dentfill(char *path, struct entry **ppdents)
+@@ -5630,6 +5716,11 @@ static int dentfill(char *path, struct entry **ppdents)
attron(COLOR_PAIR(cfg.curctx + 1));
}
#if _POSIX_C_SOURCE >= 200112L
posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
#endif
-@@ -5815,6 +5906,29 @@ static int dentfill(char *path, struct entry **ppdents)
+@@ -5830,6 +5921,29 @@ static int dentfill(char *path, struct entry **ppdents)
#endif
}
++ndents;
} while ((dp = readdir(dirp)));
-@@ -6360,11 +6474,12 @@ static int adjust_cols(int n)
+@@ -6373,11 +6487,12 @@ static int adjust_cols(int n)
#endif
if (cfg.showdetail) {
/* Fallback to light mode if less than 35 columns */
/* 2 columns for preceding space and indicator */
return (n - 2);
-@@ -8126,6 +8241,7 @@ static void usage(void)
+@@ -8144,6 +8259,7 @@ static void usage(void)
" -F val fifo mode [0:preview 1:explore]\n"
#endif
" -g regex filters\n"
+ " -G always show git status\n"
" -H show hidden files\n"
" -i show current file info\n"
- " -J no auto-jump on select\n"
-@@ -8266,6 +8382,7 @@ static void cleanup(void)
- free(hostname);
+ " -J no auto-jump on selection\n"
+@@ -8282,6 +8398,7 @@ static void cleanup(void)
+ fflush(stdout);
}
#endif
+ free(git_statuses.statuses);
free(selpath);
free(plgpath);
free(cfgpath);
-@@ -8310,7 +8427,7 @@ int main(int argc, char *argv[])
+@@ -8326,7 +8443,7 @@ int main(int argc, char *argv[])
while ((opt = (env_opts_id > 0
? env_opts[--env_opts_id]
switch (opt) {
#ifndef NOFIFO
case 'a':
-@@ -8361,6 +8478,9 @@ int main(int argc, char *argv[])
+@@ -8377,6 +8494,9 @@ int main(int argc, char *argv[])
cfg.regex = 1;
filterfn = &visible_re;
break;
# Authors: Luuk van Baal
diff --git a/src/nnn.c b/src/nnn.c
-index af586056..9ebfb203 100644
+index ee1f5beb..91aab231 100644
--- a/src/nnn.c
+++ b/src/nnn.c
-@@ -262,6 +262,25 @@
+@@ -265,6 +265,25 @@
#define FREE 0
#define CAPACITY 1
/* TYPE DEFINITIONS */
typedef unsigned int uint_t;
typedef unsigned char uchar_t;
-@@ -286,6 +305,7 @@ typedef struct entry {
+@@ -289,6 +308,7 @@ typedef struct entry {
uid_t uid; /* 4 bytes */
gid_t gid; /* 4 bytes */
#endif
} *pEntry;
/* Selection marker */
-@@ -342,6 +362,7 @@ typedef struct {
+@@ -345,6 +365,7 @@ typedef struct {
uint_t cliopener : 1; /* All-CLI app opener */
uint_t waitedit : 1; /* For ops that can't be detached, used EDITOR */
uint_t rollover : 1; /* Roll over at edges */
} settings;
/* Non-persistent program-internal states (alphabeical order) */
-@@ -395,7 +416,17 @@ static struct {
+@@ -398,7 +419,17 @@ static struct {
ushort_t maxnameln, maxsizeln, maxuidln, maxgidln, maxentln, uidln, gidln, printguid;
} dtls;
/* Configuration, contexts */
static settings cfg = {
-@@ -426,6 +457,7 @@ static settings cfg = {
+@@ -429,6 +460,7 @@ static settings cfg = {
0, /* cliopener */
0, /* waitedit */
1, /* rollover */
};
static context g_ctx[CTX_MAX] __attribute__ ((aligned));
-@@ -3847,6 +3879,56 @@ static int get_kv_key(kv *kvarr, char *val, uchar_t max, uchar_t id)
+@@ -3846,6 +3878,56 @@ static int get_kv_key(kv *kvarr, char *val, uchar_t max, uchar_t id)
return -1;
}
static void resetdircolor(int flags)
{
/* Directories are always shown on top, clear the color when moving to first file */
-@@ -4157,6 +4239,9 @@ static void printent(const struct entry *ent, uint_t namecols, bool sel)
+@@ -4163,6 +4245,9 @@ static void printent(const struct entry *ent, uint_t namecols, bool sel)
int attrs = 0, namelen;
uchar_t color_pair = get_color_pair_name_ind(ent, &ind, &attrs);
addch((ent->flags & FILE_SELECTED) ? '+' | A_REVERSE | A_BOLD : ' ');
if (g_state.oldcolor)
-@@ -5623,6 +5708,11 @@ static int dentfill(char *path, struct entry **ppdents)
+@@ -5636,6 +5721,11 @@ static int dentfill(char *path, struct entry **ppdents)
attron(COLOR_PAIR(cfg.curctx + 1));
}
#if _POSIX_C_SOURCE >= 200112L
posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
#endif
-@@ -5821,6 +5911,29 @@ static int dentfill(char *path, struct entry **ppdents)
+@@ -5836,6 +5926,29 @@ static int dentfill(char *path, struct entry **ppdents)
#endif
}
++ndents;
} while ((dp = readdir(dirp)));
-@@ -6357,7 +6470,8 @@ static int adjust_cols(int n)
+@@ -6374,7 +6487,8 @@ static int adjust_cols(int n)
cfg.showdetail ^= 1;
else /* 2 more accounted for below */
n -= (dtls.maxentln - 2 - dtls.maxnameln);
/* 2 columns for preceding space and indicator */
return (n - 2);
-@@ -6512,7 +6626,7 @@ static void redraw(char *path)
+@@ -6529,7 +6643,7 @@ static void redraw(char *path)
}
#endif
}
}
ncols = adjust_cols(ncols);
-@@ -8132,6 +8246,7 @@ static void usage(void)
+@@ -8154,6 +8268,7 @@ static void usage(void)
" -F val fifo mode [0:preview 1:explore]\n"
#endif
" -g regex filters\n"
+ " -G always show git status\n"
" -H show hidden files\n"
" -i show current file info\n"
- " -J no auto-jump on select\n"
-@@ -8272,6 +8387,7 @@ static void cleanup(void)
- free(hostname);
+ " -J no auto-jump on selection\n"
+@@ -8292,6 +8407,7 @@ static void cleanup(void)
+ fflush(stdout);
}
#endif
+ free(git_statuses.statuses);
free(selpath);
free(plgpath);
free(cfgpath);
-@@ -8316,7 +8432,7 @@ int main(int argc, char *argv[])
+@@ -8336,7 +8452,7 @@ int main(int argc, char *argv[])
while ((opt = (env_opts_id > 0
? env_opts[--env_opts_id]
switch (opt) {
#ifndef NOFIFO
case 'a':
-@@ -8367,6 +8483,9 @@ int main(int argc, char *argv[])
+@@ -8387,6 +8503,9 @@ int main(int argc, char *argv[])
cfg.regex = 1;
filterfn = &visible_re;
break;
# Author: Luuk van Baal
diff --git a/src/nnn.c b/src/nnn.c
-index 88263beb..55f32e73 100644
+index 508ee915..ee1f5beb 100644
--- a/src/nnn.c
+++ b/src/nnn.c
-@@ -390,6 +390,10 @@ typedef struct {
+@@ -394,6 +394,10 @@ typedef struct {
} session_header_t;
#endif
/* GLOBALS */
/* Configuration, contexts */
-@@ -1083,10 +1087,12 @@ static char *getpwname(uid_t uid)
+@@ -1091,10 +1095,12 @@ static char *getpwname(uid_t uid)
static char *namecache;
if (uidcache != uid) {
+ if (dtls.maxuidln && !dtls.printguid) dtls.printguid = 1;
struct passwd *pw = getpwuid(uid);
-
+
uidcache = uid;
namecache = pw ? pw->pw_name : NULL;
+ dtls.uidln = xstrlen(namecache ? namecache : xitoa(uid));
}
return namecache ? namecache : xitoa(uid);
-@@ -1098,10 +1104,12 @@ static char *getgrname(gid_t gid)
+@@ -1106,10 +1112,12 @@ static char *getgrname(gid_t gid)
static char *grpcache;
if (gidcache != gid) {
}
return grpcache ? grpcache : xitoa(gid);
-@@ -3829,14 +3837,13 @@ static void resetdircolor(int flags)
+@@ -3853,14 +3861,13 @@ static void resetdircolor(int flags)
* Max supported str length: NAME_MAX;
*/
#ifdef NOLC
{
wchar_t * const wbuf = (wchar_t *)g_buf;
wchar_t *buf = wbuf;
-@@ -3861,7 +3868,7 @@ static wchar_t *unescape(const char *str, uint_t maxcols)
+@@ -3885,7 +3892,7 @@ static wchar_t *unescape(const char *str, uint_t maxcols)
++buf;
}
}
static off_t get_size(off_t size, off_t *pval, int comp)
-@@ -4122,33 +4129,7 @@ static uchar_t get_color_pair_name_ind(const struct entry *ent, char *pind, int
+@@ -4153,33 +4160,7 @@ static uchar_t get_color_pair_name_ind(const struct entry *ent, char *pind, int
static void printent(const struct entry *ent, uint_t namecols, bool sel)
{
char ind = '\0';
- attron(attrs);
-
- /* Print details */
-- print_time(&ent->sec);
+- print_time(&ent->sec, ent->flags);
-
- printw("%s%9s ", perms, (type == S_IFREG || type == S_IFDIR)
- ? coolsize(cfg.blkorder ? (blkcnt_t)ent->blocks << blk_shift : ent->size)
uchar_t color_pair = get_color_pair_name_ind(ent, &ind, &attrs);
addch((ent->flags & FILE_SELECTED) ? '+' | A_REVERSE | A_BOLD : ' ');
-@@ -4173,15 +4154,40 @@ static void printent(const struct entry *ent, uint_t namecols, bool sel)
+@@ -4204,15 +4185,40 @@ static void printent(const struct entry *ent, uint_t namecols, bool sel)
++namecols;
#ifndef NOLC
+ attron(attrs);
+ if (!g_state.oldcolor && (type == S_IFDIR || (type == S_IFLNK && ent->flags & DIR_OR_DIRLNK)))
+ attroff(A_BOLD);
-+ size_t sizelen = (type == S_IFREG || type == S_IFDIR) ? xstrlen(size = coolsize(cfg.blkorder ? ent->blocks << blk_shift : ent->size)) : 1;
-+ printw("%*c%*s%s%s", 1 + MIN(namecols, dtls.maxnameln + (size_t)(ind ? 0 : 1)) - namelen, ' ',
++ int sizelen = (type == S_IFREG || type == S_IFDIR) ? xstrlen(size = coolsize(cfg.blkorder ? ent->blocks << blk_shift : ent->size)) : 1;
++ printw("%*c%*s%s%s", 1 + MIN(namecols, dtls.maxnameln + (uint_t)(ind ? 0 : 1)) - namelen, ' ',
+ dtls.maxsizeln - sizelen, "", size ? size : (type = (uchar_t)get_detail_ind(ent->mode), (char *)&type), " ");
+#ifndef NOUG
+ if (g_state.uidgid && dtls.printguid) {
+ }
+#endif
+ addstr(perms);
-+ print_time(&ent->sec);
++ print_time(&ent->sec, ent->flags);
+ }
+ if (attrs)
+ attroff(attrs);
}
static void savecurctx(char *path, char *curname, int nextctx)
-@@ -6250,18 +6256,6 @@ static void statusbar(char *path)
- tocursor();
+@@ -6357,14 +6363,6 @@ static void statusbar(char *path)
+ tocursor();
}
-static inline void markhovered(void)
-{
-- if (cfg.showdetail && ndents) { /* Reversed block for hovered entry */
+- if (cfg.showdetail && ndents) { /* Bold forward arrowhead */
- tocursor();
--#ifdef ICONS_ENABLED
-- addstr(MD_ARROW_FORWARD);
--#else
-- addch(' ' | A_REVERSE);
--#endif
+- addch('>' | A_BOLD);
- }
-}
-
static int adjust_cols(int n)
{
/* Calculate the number of cols available to print entry name */
-@@ -6269,11 +6263,10 @@ static int adjust_cols(int n)
- n -= (g_state.oldcolor ? 0 : 1 + xstrlen(ICON_PADDING_LEFT) + xstrlen(ICON_PADDING_RIGHT));
+@@ -6372,11 +6370,10 @@ static int adjust_cols(int n)
+ n -= (g_state.oldcolor ? 0 : 1 + ICON_PADDING_LEFT_LEN + ICON_PADDING_RIGHT_LEN);
#endif
if (cfg.showdetail) {
- /* Fallback to light mode if less than 35 columns */
}
/* 2 columns for preceding space and indicator */
-@@ -6310,8 +6303,6 @@ static void draw_line(int ncols)
+@@ -6413,8 +6410,6 @@ static void draw_line(int ncols)
/* Must reset e.g. no files in dir */
if (dir)
attroff(COLOR_PAIR(cfg.curctx + 1) | A_BOLD);
}
static void redraw(char *path)
-@@ -6419,6 +6410,21 @@ static void redraw(char *path)
-
+@@ -6522,6 +6517,21 @@ static void redraw(char *path)
+
onscreen = MIN(onscreen + curscroll, ndents);
+ if (cfg.showdetail) {
ncols = adjust_cols(ncols);
int len = scanselforpath(path, FALSE);
-@@ -6449,7 +6455,7 @@ static void redraw(char *path)
+@@ -6552,7 +6562,7 @@ static void redraw(char *path)
#endif
}
# Authors: Luuk van Baal
diff --git a/src/nnn.c b/src/nnn.c
-index 4243f2cc..b893f573 100644
+index 508ee915..31aa6b53 100644
--- a/src/nnn.c
+++ b/src/nnn.c
-@@ -370,7 +370,8 @@ typedef struct {
+@@ -371,7 +371,8 @@ typedef struct {
uint_t stayonsel : 1; /* Disable auto-jump on select */
uint_t trash : 2; /* Trash method 0: rm -rf, 1: trash-cli, 2: gio trash */
uint_t uidgid : 1; /* Show owner and group info */
} runstate;
/* Contexts or workspaces */
-@@ -518,6 +519,9 @@ static char g_tmpfpath[TMP_LEN_MAX] __attribute__ ((aligned));
+@@ -520,6 +521,9 @@ static char g_tmpfpath[TMP_LEN_MAX] __attribute__ ((aligned));
/* Buffer to store plugins control pipe location */
static char g_pipepath[TMP_LEN_MAX] __attribute__ ((aligned));
/* Non-persistent runtime states */
static runstate g_state;
-@@ -692,12 +696,13 @@ static const char * const messages[] = {
+@@ -694,12 +698,13 @@ static const char * const messages[] = {
#define NNN_FCOLORS 5
#define NNNLVL 6
#define NNN_PIPE 7
static const char * const env_cfg[] = {
"NNN_OPTS",
-@@ -708,6 +713,7 @@ static const char * const env_cfg[] = {
+@@ -710,6 +715,7 @@ static const char * const env_cfg[] = {
"NNN_FCOLORS",
"NNNLVL",
"NNN_PIPE",
"NNN_MCLICK",
"NNN_SEL",
"NNN_ARCHIVE",
-@@ -854,7 +860,7 @@ static int set_sort_flags(int r);
+@@ -856,7 +862,7 @@ 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
#endif
/* Functions */
-@@ -3061,7 +3067,7 @@ try_quit:
+@@ -3063,7 +3069,7 @@ try_quit:
} else {
#ifndef NOFIFO
if (!g_state.fifomode)
#endif
escaped = TRUE;
settimeout();
-@@ -5160,15 +5166,20 @@ static bool run_cmd_as_plugin(const char *file, char *runfile, uchar_t flags)
+@@ -5171,15 +5177,20 @@ static bool run_cmd_as_plugin(const char *file, char *runfile, uchar_t flags)
static bool plctrl_init(void)
{
return EXIT_SUCCESS;
}
-@@ -5197,6 +5208,21 @@ static ssize_t read_nointr(int fd, void *buf, size_t count)
+@@ -5208,6 +5219,21 @@ static ssize_t read_nointr(int fd, void *buf, size_t count)
return len;
}
static char *readpipe(int fd, char *ctxnum, char **path)
{
char ctx, *nextpath = NULL;
-@@ -5862,7 +5888,7 @@ static void populate(char *path, char *lastname)
+@@ -5881,7 +5907,7 @@ static void populate(char *path, char *lastname)
}
#ifndef NOFIFO
{
if (!fifopath)
return;
-@@ -5878,6 +5904,12 @@ static void notify_fifo(bool force)
+@@ -5897,6 +5923,12 @@ static void notify_fifo(bool force)
}
}
static struct entry lastentry;
if (!force && !memcmp(&lastentry, &pdents[cur], sizeof(struct entry)))
-@@ -5910,7 +5942,7 @@ static void send_to_explorer(int *presel)
+@@ -5929,7 +5961,7 @@ static void send_to_explorer(int *presel)
if (fd > 1)
close(fd);
} else
}
#endif
-@@ -5943,7 +5975,7 @@ static void move_cursor(int target, int ignore_scrolloff)
+@@ -5962,7 +5994,7 @@ static void move_cursor(int target, int ignore_scrolloff)
#ifndef NOFIFO
if (!g_state.fifomode)
#endif
}
-@@ -6565,7 +6597,7 @@ static bool browse(char *ipath, const char *session, int pkey)
+@@ -6580,7 +6612,7 @@ static bool browse(char *ipath, const char *session, int pkey)
pEntry pent;
enum action sel;
struct stat sb;
const uchar_t opener_flags = (cfg.cliopener ? F_CLI : (F_NOTRACE | F_NOSTDIN | F_NOWAIT));
bool watch = FALSE, cd = TRUE;
ino_t inode = 0;
-@@ -6819,7 +6851,7 @@ nochange:
+@@ -6838,7 +6870,7 @@ nochange:
move_cursor(r, 1);
#ifndef NOFIFO
else if ((event.bstate == BUTTON1_PRESSED) && !g_state.fifomode)
#endif
/* Handle right click selection */
if (event.bstate == BUTTON3_PRESSED) {
-@@ -6979,7 +7011,14 @@ nochange:
+@@ -6998,7 +7030,14 @@ nochange:
&& strstr(g_buf, "text")
#endif
) {
if (cfg.filtermode) {
presel = FILTER;
clearfilter();
-@@ -7291,8 +7330,14 @@ nochange:
+@@ -7308,8 +7347,14 @@ nochange:
copycurname();
goto nochange;
case SEL_EDIT:
continue;
default: /* SEL_LOCK */
lock_terminal();
-@@ -7661,6 +7706,7 @@ nochange:
+@@ -7678,6 +7723,7 @@ nochange:
cd = FALSE;
goto begin;
}
case SEL_PLUGIN:
/* Check if directory is accessible */
if (!xdiraccess(plgpath)) {
-@@ -7686,6 +7732,12 @@ nochange:
+@@ -7703,6 +7749,12 @@ nochange:
goto nochange;
}
if (tmp[0] == '-' && tmp[1]) {
++tmp;
r = FALSE; /* Do not refresh dir after completion */
-@@ -7740,7 +7792,13 @@ nochange:
+@@ -7757,7 +7809,13 @@ nochange:
case SEL_SHELL: // fallthrough
case SEL_LAUNCH: // fallthrough
case SEL_PROMPT:
/* Continue in type-to-nav mode, if enabled */
if (cfg.filtermode)
-@@ -8282,8 +8340,10 @@ static void cleanup(void)
+@@ -8297,8 +8355,10 @@ static void cleanup(void)
if (g_state.autofifo)
unlink(fifopath);
#endif
#ifdef DEBUG
disabledbg();
#endif
-@@ -8787,7 +8847,7 @@ int main(int argc, char *argv[])
+@@ -8796,7 +8856,7 @@ int main(int argc, char *argv[])
#ifndef NOFIFO
if (!g_state.fifomode)