]> Sergey Matveev's repositories - nnn.git/commitdiff
Use a shorter width param
authorArun Prakash Jana <engineerarun@gmail.com>
Wed, 1 Jan 2020 21:32:53 +0000 (03:02 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Wed, 1 Jan 2020 21:33:21 +0000 (03:03 +0530)
src/nnn.c

index 23ce7f9b3e28eb23b0ab865c1c97bfc12c3d5fe1..b8a92f1aef06d35b136ec883b19b964b56c3e30f 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2682,7 +2682,7 @@ static char *get_lsperms(mode_t mode)
        return bits;
 }
 
-static void printent(const struct entry *ent, int sel, uint namecols)
+static void printent(const struct entry *ent, uint namecols, bool sel)
 {
        wchar_t *wstr;
        char ind = '\0';
@@ -2733,7 +2733,7 @@ static void printent(const struct entry *ent, int sel, uint namecols)
                attroff(A_REVERSE);
 }
 
-static void printent_long(const struct entry *ent, int sel, uint namecols)
+static void printent_long(const struct entry *ent, uint namecols, bool sel)
 {
        char timebuf[24], permbuf[4], ind1 = '\0', ind2[] = "\0\0";
        const char cp = (ent->flags & FILE_SELECTED) ? '+' : ' ';
@@ -2799,7 +2799,7 @@ static void printent_long(const struct entry *ent, int sel, uint namecols)
                attroff(A_REVERSE);
 }
 
-static void (*printptr)(const struct entry *ent, int sel, uint namecols) = &printent;
+static void (*printptr)(const struct entry *ent, uint namecols, bool sel) = &printent;
 
 static void savecurctx(settings *curcfg, char *path, char *curname, int r /* next context num */)
 {
@@ -4122,20 +4122,15 @@ static void redraw(char *path)
        for (i = 0; i < CTX_MAX; ++i) {
                if (!g_ctx[i].c_cfg.ctxactive) {
                        addch(i + '1');
-                       addch(' ');
                } else {
-                       if (cfg.curctx != i)
-                               /* Underline active contexts */
-                               attrs = COLOR_PAIR(i + 1) | A_BOLD | A_UNDERLINE;
-                       else
-                               /* Print current context in reverse */
-                               attrs = COLOR_PAIR(i + 1) | A_BOLD | A_REVERSE;
-
+                       attrs = (cfg.curctx != i)
+                                ? (COLOR_PAIR(i + 1) | A_BOLD | A_UNDERLINE) /* Underline active */
+                                : (COLOR_PAIR(i + 1) | A_BOLD | A_REVERSE); /* Current in reverse */
                        attron(attrs);
                        addch(i + '1');
                        attroff(attrs);
-                       addch(' ');
                }
+               addch(' ');
        }
        addstr("\b] "); /* 10 chars printed for contexts - "[1 2 3 4] " */
 
@@ -4192,7 +4187,7 @@ static void redraw(char *path)
 
        /* Print listing */
        for (i = curscroll; i < ndents && i < curscroll + onscreen; ++i)
-               printptr(&dents[i], i == cur, ncols);
+               printptr(&dents[i], ncols, i == cur);
 
        /* Must reset e.g. no files in dir */
        if (cfg.dircolor) {