mirror of
https://github.com/jarun/nnn.git
synced 2025-03-18 20:39:45 +00:00
Reformat entry printing
This commit is contained in:
parent
71bac356d6
commit
07437a897c
1 changed files with 17 additions and 11 deletions
28
src/nnn.c
28
src/nnn.c
|
@ -2975,12 +2975,12 @@ static void resetdircolor(int flags)
|
||||||
*/
|
*/
|
||||||
static wchar_t *unescape(const char *str, uint maxcols)
|
static wchar_t *unescape(const char *str, uint maxcols)
|
||||||
{
|
{
|
||||||
static wchar_t wbuf[NAME_MAX + 1] __attribute__ ((aligned));
|
wchar_t * const wbuf = (wchar_t *)g_buf;
|
||||||
wchar_t *buf = wbuf;
|
wchar_t *buf = wbuf;
|
||||||
size_t lencount = 0;
|
size_t lencount = 0;
|
||||||
|
|
||||||
#ifdef NOLOCALE
|
#ifdef NOLOCALE
|
||||||
memset(wbuf, 0, sizeof(wbuf));
|
memset(wbuf, 0, sizeof(NAME_MAX + 1));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Convert multi-byte to wide char */
|
/* Convert multi-byte to wide char */
|
||||||
|
@ -3172,17 +3172,16 @@ static void printent(const struct entry *ent, uint namecols, bool sel)
|
||||||
|
|
||||||
static void printent_long(const struct entry *ent, uint namecols, bool sel)
|
static void printent_long(const struct entry *ent, uint namecols, bool sel)
|
||||||
{
|
{
|
||||||
char timebuf[24], permbuf[4], ind1 = '\0', ind2 = '\0';
|
char timebuf[18], permbuf[8] = " ", ind1 = '\0', ind2 = '\0', special = '\0';
|
||||||
|
|
||||||
/* Timestamp */
|
/* Timestamp */
|
||||||
strftime(timebuf, sizeof(timebuf), "%F %R", localtime(&ent->t));
|
strftime(timebuf, sizeof(timebuf), "%F %R", localtime(&ent->t));
|
||||||
timebuf[sizeof(timebuf)-1] = '\0';
|
//timebuf[sizeof(timebuf)-1] = '\0';
|
||||||
|
|
||||||
/* Permissions */
|
/* Permissions */
|
||||||
permbuf[0] = '0' + ((ent->mode >> 6) & 7);
|
permbuf[2] = '0' + ((ent->mode >> 6) & 7);
|
||||||
permbuf[1] = '0' + ((ent->mode >> 3) & 7);
|
permbuf[3] = '0' + ((ent->mode >> 3) & 7);
|
||||||
permbuf[2] = '0' + (ent->mode & 7);
|
permbuf[4] = '0' + (ent->mode & 7);
|
||||||
permbuf[3] = '\0';
|
|
||||||
|
|
||||||
/* Add a column if no indicator is needed */
|
/* Add a column if no indicator is needed */
|
||||||
if (S_ISREG(ent->mode) && !(ent->mode & 0100))
|
if (S_ISREG(ent->mode) && !(ent->mode & 0100))
|
||||||
|
@ -3196,6 +3195,9 @@ static void printent_long(const struct entry *ent, uint namecols, bool sel)
|
||||||
if (sel)
|
if (sel)
|
||||||
attron(A_REVERSE);
|
attron(A_REVERSE);
|
||||||
|
|
||||||
|
addstr(timebuf);
|
||||||
|
addstr(permbuf);
|
||||||
|
|
||||||
switch (ent->mode & S_IFMT) {
|
switch (ent->mode & S_IFMT) {
|
||||||
case S_IFREG:
|
case S_IFREG:
|
||||||
ind1 = (ent->flags & HARD_LINK) ? '>' : ' ';
|
ind1 = (ent->flags & HARD_LINK) ? '>' : ' ';
|
||||||
|
@ -3207,8 +3209,7 @@ static void printent_long(const struct entry *ent, uint namecols, bool sel)
|
||||||
ind2 = '/';
|
ind2 = '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
printw("%-16.16s %s %8.8s%c ", timebuf, permbuf,
|
printw("%8.8s", coolsize(cfg.blkorder ? ent->blocks << blk_shift : ent->size));
|
||||||
coolsize(cfg.blkorder ? ent->blocks << blk_shift : ent->size), ind1);
|
|
||||||
break;
|
break;
|
||||||
case S_IFLNK:
|
case S_IFLNK:
|
||||||
ind1 = ind2 = '@'; // fallthrough
|
ind1 = ind2 = '@'; // fallthrough
|
||||||
|
@ -3227,10 +3228,15 @@ static void printent_long(const struct entry *ent, uint namecols, bool sel)
|
||||||
default:
|
default:
|
||||||
if (!ind1)
|
if (!ind1)
|
||||||
ind1 = ind2 = '?';
|
ind1 = ind2 = '?';
|
||||||
printw("%-16.16s %s %c ", timebuf, permbuf, ind1);
|
addstr(" ");
|
||||||
|
special = ' ';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addch(ind1);
|
||||||
|
addch(' ');
|
||||||
|
if (special)
|
||||||
|
addch(special);
|
||||||
addwstr(unescape(ent->name, namecols));
|
addwstr(unescape(ent->name, namecols));
|
||||||
if (sel)
|
if (sel)
|
||||||
attroff(A_REVERSE);
|
attroff(A_REVERSE);
|
||||||
|
|
Loading…
Add table
Reference in a new issue