]> Sergey Matveev's repositories - nnn.git/commitdiff
Show order info in filter info bar
authorArun Prakash Jana <engineerarun@gmail.com>
Tue, 14 Jan 2020 17:21:10 +0000 (22:51 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Tue, 14 Jan 2020 17:21:10 +0000 (22:51 +0530)
README.md
src/nnn.c

index 29adf859c363469b3dc12d1aa977f5072c601a9a..8b38d55f297f6632218b24743509a71bcb026103 100644 (file)
--- a/README.md
+++ b/README.md
@@ -26,11 +26,12 @@ It runs smoothly on the Pi, [Termux](https://www.youtube.com/watch?v=AbaauM7gUJw
 ## Features
 
 - Resource sensitive
-  - Typically needs < 3.5MB resident memory
+  - Typically needs less than 3.5MB resident memory
   - Works with 8-bit colors
   - Disk-IO sensitive (few disk reads and writes)
   - No FPU usage (all integer maths, even for file size)
   - Minimizes screen refresh with fast line redraws
+  - Tiny binary (typically less than 100KB)
 - Portable
   - Minimal library deps, easily compilable, tiny binary
   - No config file, minimal config with sensible defaults
index fdc1c22862fc3a73b32a8f2d32a7b1ed4a643ced..705725a0c5e8cb1b2457c89e4c3a0e97cb80ec18 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2028,11 +2028,44 @@ static int nextsel(int presel)
        return 0;
 }
 
+static int getorderstr(char *sort)
+{
+       int i = 0;
+
+       if (cfg.mtimeorder)
+               sort[0] = cfg.mtime ? 'T' : 'A';
+       else if (cfg.sizeorder)
+               sort[0] = 'S';
+       else if (cfg.extnorder)
+               sort[0] = 'E';
+
+       if (sort[i])
+               ++i;
+
+       if (entrycmpfn == &reventrycmp) {
+               sort[i] = 'R';
+               ++i;
+       }
+
+       if (namecmpfn == &xstrverscasecmp) {
+               sort[i] = 'V';
+               ++i;
+       }
+
+       if (i)
+               sort[i] = ' ';
+
+       return i;
+}
+
 static void showfilterinfo(void)
 {
-       char info[REGEX_MAX];
+       int i = 0;
+       char info[REGEX_MAX] = "\0\0\0\0";
 
-       snprintf(info, REGEX_MAX - 1, "    %s [keys /\\], %s [key :]",
+       i = getorderstr(info);
+
+       snprintf(info + i, REGEX_MAX - i - 1, "  %s [keys /\\], %s [key :]",
                 (cfg.regex ? "regex" : "str"),
                 ((fnstrstr == &strcasestr) ? "ic" : "noic"));
        printinfoln(info);
@@ -4230,7 +4263,6 @@ static void statusbar(char *path)
 {
        int i = 0, extnlen = 0;
        char *ptr;
-       char sort[] = "\0\0\0\0";
        char buf[24];
        pEntry pent = &dents[cur];
 
@@ -4239,29 +4271,6 @@ static void statusbar(char *path)
                return;
        }
 
-       if (cfg.mtimeorder)
-               sort[0] = cfg.mtime ? 'T' : 'A';
-       else if (cfg.sizeorder)
-               sort[0] = 'S';
-       else if (cfg.extnorder)
-               sort[0] = 'E';
-
-       if (sort[i])
-               ++i;
-
-       if (entrycmpfn == &reventrycmp) {
-               sort[i] = 'R';
-               ++i;
-       }
-
-       if (namecmpfn == &xstrverscasecmp) {
-               sort[i] = 'V';
-               ++i;
-       }
-
-       if (i)
-               sort[i] = ' ';
-
        /* Get the file extension for regular files */
        if (S_ISREG(pent->mode)) {
                i = (int)(pent->nlen - 1);
@@ -4287,6 +4296,9 @@ static void statusbar(char *path)
                /* Show filename as it may be truncated in directory listing */
                /* Get the unescaped file name */
                char *fname = unescape(pent->name, NAME_MAX, NULL);
+               char sort[] = "\0\0\0\0";
+
+               getorderstr(sort);
 
                /* Timestamp */
                strftime(buf, sizeof(buf), "%F %R", localtime(&pent->t));