]> Sergey Matveev's repositories - nnn.git/commitdiff
Simpler regular listing
authorArun Prakash Jana <engineerarun@gmail.com>
Wed, 29 Mar 2017 20:55:51 +0000 (02:25 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Wed, 29 Mar 2017 20:55:51 +0000 (02:25 +0530)
README.md
noice.c

index 2a2d80b7a64debec9e68df6be08ab28c5858bfeb..9f8e03ce8b45833de31485ab651081b9be1206c7 100644 (file)
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ I chose to fork noice because:
 ### Fork toppings
 
 - Behaviour and navigation
-  - Optional detailed view with file type and size (default: disabled)
+  - Optional detail view with file type and size (default: disabled)
   - Case-insensitive alphabetic content listing instead of upper case first
   - Roll over at the first and last entries of a directory (with Up/Down keys)
   - Sort entries by file size (largest to smallest)
@@ -98,7 +98,7 @@ Start noice (default: current directory):
 | `~` | jump to home dir |
 | `/`, `&` | filter dir contents |
 | `c` | show change dir prompt |
-| 'd' | toggle detail view |
+| `d` | toggle detail view |
 | `.` | toggle hide dot files |
 | `s` | toggle sort by file size |
 | `t` | toggle sort by modified time |
diff --git a/noice.c b/noice.c
index 96bc5a1e8165825e53814b5b1202cb8f843831f8..1af0e9a7b9164998f6f6bb6f07434dd3d750009b 100644 (file)
--- 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