Dim links

This commit is contained in:
Arun Prakash Jana 2020-02-26 23:24:26 +05:30
parent 987cc9b4b3
commit f12bf0a2ee
No known key found for this signature in database
GPG Key ID: A75979F35C080412
1 changed files with 26 additions and 27 deletions

View File

@ -3142,13 +3142,11 @@ static char *get_lsperms(mode_t mode)
static void printent(const struct entry *ent, uint namecols, bool sel) static void printent(const struct entry *ent, uint namecols, bool sel)
{ {
char hln = '\0';
char ind = get_ind(ent->mode, FALSE); char ind = get_ind(ent->mode, FALSE);
int attrs = sel ? A_REVERSE : 0;
if (S_ISREG(ent->mode) && (ent->flags & HARD_LINK)) { if ((S_ISREG(ent->mode) && (ent->flags & HARD_LINK)) || ind == '@')
hln = '>'; attrs |= A_DIM;
--namecols;
}
if (!ind) if (!ind)
++namecols; ++namecols;
@ -3158,21 +3156,22 @@ static void printent(const struct entry *ent, uint namecols, bool sel)
addch((ent->flags & FILE_SELECTED) ? '+' : ' '); addch((ent->flags & FILE_SELECTED) ? '+' : ' ');
if (sel) if (attrs)
attron(A_REVERSE); attron(attrs);
addwstr(unescape(ent->name, namecols)); addwstr(unescape(ent->name, namecols));
if (sel) if (attrs)
attroff(A_REVERSE); attroff(attrs);
if (ind) if (ind)
addch(ind); addch(ind);
if (hln)
addch(hln);
addch('\n'); addch('\n');
} }
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[18], permbuf[8], ind1 = '\0', ind2 = '\0', special = '\0'; bool ln = FALSE;
char timebuf[18], permbuf[8], ind1 = '\0', ind2 = '\0';
int attrs = sel ? A_REVERSE : 0;
size_t len; size_t len;
char *size; char *size;
@ -3192,25 +3191,23 @@ static void printent_long(const struct entry *ent, uint namecols, bool sel)
addch((ent->flags & FILE_SELECTED) ? '+' : ' '); addch((ent->flags & FILE_SELECTED) ? '+' : ' ');
if (sel) if (attrs)
attron(A_REVERSE); attron(attrs);
addstr(timebuf); addstr(timebuf);
addstr(permbuf); addstr(permbuf);
switch (ent->mode & S_IFMT) { switch (ent->mode & S_IFMT) {
case S_IFREG: case S_IFREG:
ind1 = (ent->flags & HARD_LINK) ? '>' : ' '; if (ent->flags & HARD_LINK)
ln = TRUE;
if (ent->mode & 0100) if (ent->mode & 0100)
ind2 = '*'; ind2 = '*';
else /* Add a column if no indicator is needed */
++namecols;
// fallthrough // fallthrough
case S_IFDIR: case S_IFDIR:
if (!ind1) { if (!ind2) /* Add a column if end indicator is not needed */
ind1 = ' ';
++namecols; ++namecols;
}
size = coolsize(cfg.blkorder ? ent->blocks << blk_shift : ent->size); size = coolsize(cfg.blkorder ? ent->blocks << blk_shift : ent->size);
len = 9 - strlen(size); len = 9 - strlen(size);
@ -3219,6 +3216,7 @@ static void printent_long(const struct entry *ent, uint namecols, bool sel)
addstr(size); addstr(size);
break; break;
case S_IFLNK: case S_IFLNK:
ln = TRUE;
ind1 = ind2 = '@'; // fallthrough ind1 = ind2 = '@'; // fallthrough
case S_IFSOCK: case S_IFSOCK:
if (!ind1) if (!ind1)
@ -3236,17 +3234,18 @@ static void printent_long(const struct entry *ent, uint namecols, bool sel)
if (!ind1) if (!ind1)
ind1 = ind2 = '?'; ind1 = ind2 = '?';
addstr(" "); addstr(" ");
special = ' '; addch(ind1);
break; break;
} }
addch(ind1); addstr(" ");
addch(' '); if (ln) {
if (special) attron(A_DIM);
addch(special); attrs |= A_DIM;
}
addwstr(unescape(ent->name, namecols)); addwstr(unescape(ent->name, namecols));
if (sel) if (attrs)
attroff(A_REVERSE); attroff(attrs);
if (ind2) if (ind2)
addch(ind2); addch(ind2);
addch('\n'); addch('\n');