mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
Code refactor
This commit is contained in:
parent
11b317020d
commit
2a571d9b0d
36
src/nnn.c
36
src/nnn.c
|
@ -1832,7 +1832,7 @@ static char *get_bm_loc(char *buf, int key)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resetdircolor(int flags)
|
static inline void resetdircolor(int flags)
|
||||||
{
|
{
|
||||||
if (cfg.dircolor && !(flags & DIR_OR_LINK_TO_DIR)) {
|
if (cfg.dircolor && !(flags & DIR_OR_LINK_TO_DIR)) {
|
||||||
attroff(COLOR_PAIR(cfg.curctx + 1) | A_BOLD);
|
attroff(COLOR_PAIR(cfg.curctx + 1) | A_BOLD);
|
||||||
|
@ -1861,11 +1861,11 @@ static char *unescape(const char *str, uint maxcols)
|
||||||
/* Convert multi-byte to wide char */
|
/* Convert multi-byte to wide char */
|
||||||
len = mbstowcs(wbuf, str, PATH_MAX);
|
len = mbstowcs(wbuf, str, PATH_MAX);
|
||||||
|
|
||||||
g_buf[0] = '\0';
|
//g_buf[0] = '\0';
|
||||||
|
|
||||||
if (maxcols) {
|
if (maxcols) {
|
||||||
len = lencount = wcswidth(wbuf, len);
|
len = lencount = wcswidth(wbuf, len);
|
||||||
/* Reduce nuber of wide chars to max columns */
|
/* Reduce number of wide chars to max columns */
|
||||||
if (len > maxcols)
|
if (len > maxcols)
|
||||||
lencount = maxcols + 1;
|
lencount = maxcols + 1;
|
||||||
|
|
||||||
|
@ -1991,13 +1991,19 @@ static void printent(const struct entry *ent, int sel, uint namecols)
|
||||||
|
|
||||||
static void printent_long(const struct entry *ent, int sel, uint namecols)
|
static void printent_long(const struct entry *ent, int sel, uint namecols)
|
||||||
{
|
{
|
||||||
char timebuf[18], permbuf[4], cp = ' ';
|
char timebuf[18], permbuf[4], ind1 = '\0', ind2[] = "\0\0", cp = ' ';
|
||||||
|
|
||||||
/* Timestamp */
|
/* Timestamp */
|
||||||
strftime(timebuf, 18, "%F %R", localtime(&ent->t));
|
strftime(timebuf, 18, "%F %R", localtime(&ent->t));
|
||||||
|
|
||||||
/* Permissions */
|
/* Permissions */
|
||||||
snprintf(permbuf, 4, "%d%d%d", (ent->mode >> 6) & 7, (ent->mode >> 3) & 7, ent->mode & 7);
|
permbuf[0] = *xitoa((ent->mode >> 6) & 7);
|
||||||
|
permbuf[0] = permbuf[0] ? permbuf[0] : '0';
|
||||||
|
permbuf[1] = *xitoa((ent->mode >> 3) & 7);
|
||||||
|
permbuf[1] = permbuf[1] ? permbuf[1] : '0';
|
||||||
|
permbuf[2] = *xitoa(ent->mode & 7);
|
||||||
|
permbuf[2] = permbuf[2] ? permbuf[2] : '0';
|
||||||
|
permbuf[3] = '\0';
|
||||||
|
|
||||||
/* Add copy indicator */
|
/* Add copy indicator */
|
||||||
if (ent->flags & FILE_COPIED)
|
if (ent->flags & FILE_COPIED)
|
||||||
|
@ -2035,20 +2041,20 @@ static void printent_long(const struct entry *ent, int sel, uint namecols)
|
||||||
printw("%c%-16.16s 0%s @ %s@\n", cp, timebuf, permbuf, pname);
|
printw("%c%-16.16s 0%s @ %s@\n", cp, timebuf, permbuf, pname);
|
||||||
break;
|
break;
|
||||||
case S_IFSOCK:
|
case S_IFSOCK:
|
||||||
printw("%c%-16.16s 0%s = %s=\n", cp, timebuf, permbuf, pname);
|
ind1 = ind2[0] = '='; // fallthrough
|
||||||
break;
|
|
||||||
case S_IFIFO:
|
case S_IFIFO:
|
||||||
printw("%c%-16.16s 0%s | %s|\n", cp, timebuf, permbuf, pname);
|
if (!ind1)
|
||||||
break;
|
ind1 = ind2[0] = '|'; // fallthrough
|
||||||
case S_IFBLK:
|
case S_IFBLK:
|
||||||
printw("%c%-16.16s 0%s b %s\n", cp, timebuf, permbuf, pname);
|
if (!ind1)
|
||||||
break;
|
ind1 = 'b'; // fallthrough
|
||||||
case S_IFCHR:
|
case S_IFCHR:
|
||||||
printw("%c%-16.16s 0%s c %s\n", cp, timebuf, permbuf, pname);
|
if (!ind1)
|
||||||
break;
|
ind1 = 'c'; // fallthrough
|
||||||
default:
|
default:
|
||||||
printw("%c%-16.16s 0%s %8.8s? %s?\n", cp, timebuf, permbuf,
|
if (!ind1)
|
||||||
coolsize(cfg.blkorder ? ent->blocks << BLK_SHIFT : ent->size), pname);
|
ind1 = ind2[0] = '?';
|
||||||
|
printw("%c%-16.16s 0%s %c %s%s\n", cp, timebuf, permbuf, ind1, pname, ind2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue