]> Sergey Matveev's repositories - nnn.git/commitdiff
Minor refactor
authorArun Prakash Jana <engineerarun@gmail.com>
Sat, 11 Apr 2020 17:46:59 +0000 (23:16 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Sat, 11 Apr 2020 18:18:05 +0000 (23:48 +0530)
src/nnn.c

index 7a94c1442f7468e5cef128c8c4e6ec0a28d7c86f..05c865a810d0a479b241e377fd55a59dfdc3a5da 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -5000,7 +5000,7 @@ static void redraw(char *path)
 
        int ncols = (xcols <= PATH_MAX) ? xcols : PATH_MAX;
        int onscreen = xlines - 4;
-       int i, attrs;
+       int i;
        char *ptr = path;
 
        // Fast redraw
@@ -5031,16 +5031,12 @@ static void redraw(char *path)
 
        addch('[');
        for (i = 0; i < CTX_MAX; ++i) {
-               if (!g_ctx[i].c_cfg.ctxactive) {
+               if (!g_ctx[i].c_cfg.ctxactive)
                        addch(i + '1');
-               } else {
-                       attrs = COLOR_PAIR(i + 1) | A_BOLD
+               else
+                       addch((i + '1') | (COLOR_PAIR(i + 1) | A_BOLD
                                /* active: underline, current: reverse */
-                               | ((cfg.curctx != i) ? A_UNDERLINE : A_REVERSE );
-                       attron(attrs);
-                       addch(i + '1');
-                       attroff(attrs);
-               }
+                               | ((cfg.curctx != i) ? A_UNDERLINE : A_REVERSE)));
                addch(' ');
        }
        addstr("\b] "); /* 10 chars printed for contexts - "[1 2 3 4] " */
@@ -5052,13 +5048,11 @@ static void redraw(char *path)
        if ((i + MIN_DISPLAY_COLS) <= ncols)
                addnstr(path, ncols - MIN_DISPLAY_COLS);
        else {
-               char *base = xmemrchr((uchar *)path, '/', i);;
+               char *base = xmemrchr((uchar *)path, '/', i);
 
-               if ((base - ptr) <= 1)
-                       addnstr(path, ncols - MIN_DISPLAY_COLS);
-               else {
-                       i = 0;
-                       --base;
+               i = 0;
+
+               if (base != ptr) {
                        while (ptr < base) {
                                if (*ptr == '/') {
                                        i += 2; /* 2 characters added */
@@ -5072,9 +5066,9 @@ static void redraw(char *path)
                                }
                                ++ptr;
                        }
-
-                       addnstr(base, ncols - (MIN_DISPLAY_COLS + i));
                }
+
+               addnstr(base, ncols - (MIN_DISPLAY_COLS + i));
        }
 
        attroff(A_UNDERLINE);