aboutsummaryrefslogtreecommitdiffstats
path: root/noice.c
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-03-30 02:25:51 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2017-03-30 02:25:51 +0530
commit98e3f22cb4960d026649807e7dfd9048ea452a46 (patch)
tree579bfc429d1a4ba4c424a4e03b0030bd842c46bd /noice.c
parent5c7aaa6d0d10bdc1c1135b9a9cfd0d7e181303ef (diff)
downloadnnn-98e3f22cb4960d026649807e7dfd9048ea452a46.tar.gz
Simpler regular listing
Diffstat (limited to 'noice.c')
-rw-r--r--noice.c48
1 files changed, 15 insertions, 33 deletions
diff --git a/noice.c b/noice.c
index 96bc5a1..1af0e9a 100644
--- a/noice.c
+++ b/noice.c
@@ -420,38 +420,18 @@ mkpath(char *dir, char *name, char *out, size_t n)
void
printent(struct entry *ent, int active)
{
- char name[PATH_MAX];
- unsigned int maxlen = COLS - strlen(CURSR) - 1;
- char cm = 0;
-
- /* Copy name locally */
- strlcpy(name, ent->name, sizeof(name));
-
- if (S_ISDIR(ent->mode)) {
- cm = '/';
- maxlen--;
- } else if (S_ISLNK(ent->mode)) {
- cm = '@';
- maxlen--;
- } else if (S_ISSOCK(ent->mode)) {
- cm = '=';
- maxlen--;
- } else if (S_ISFIFO(ent->mode)) {
- cm = '|';
- maxlen--;
- } else if (ent->mode & S_IXUSR) {
- cm = '*';
- maxlen--;
- }
-
- /* No text wrapping in entries */
- if (strlen(name) > maxlen)
- name[maxlen] = '\0';
-
- if (cm == 0)
- printw("%s%s\n", active ? CURSR : EMPTY, name);
+ if (S_ISDIR(ent->mode))
+ printw("%s%s/\n", active ? CURSR : EMPTY, ent->name);
+ else if (S_ISLNK(ent->mode))
+ printw("%s%s@\n", active ? CURSR : EMPTY, ent->name);
+ else if (S_ISSOCK(ent->mode))
+ printw("%s%s=\n", active ? CURSR : EMPTY, ent->name);
+ else if (S_ISFIFO(ent->mode))
+ printw("%s%s|\n", active ? CURSR : EMPTY, ent->name);
+ else if (ent->mode & S_IXUSR)
+ printw("%s%s*\n", active ? CURSR : EMPTY, ent->name);
else
- printw("%s%s%c\n", active ? CURSR : EMPTY, name, cm);
+ printw("%s%s\n", active ? CURSR : EMPTY, ent->name);
}
char*
@@ -485,9 +465,11 @@ printent_long(struct entry *ent, int active)
else if (S_ISCHR(ent->mode))
printw("%s%-32.32s C\n", active ? CURSR : EMPTY, ent->name);
else if (ent->mode & S_IXUSR)
- printw("%s%-32.32s E %s\n", active ? CURSR : EMPTY, ent->name, coolsize(ent->size));
+ printw("%s%-32.32s E %s\n", active ? CURSR : EMPTY, ent->name,
+ coolsize(ent->size));
else
- printw("%s%-32.32s R %s\n", active ? CURSR : EMPTY, ent->name, coolsize(ent->size));
+ printw("%s%-32.32s R %s\n", active ? CURSR : EMPTY, ent->name,
+ coolsize(ent->size));
}
int