Code

list_window: simplified the selection painting code
authorMax Kellermann <max@duempel.org>
Fri, 9 Oct 2009 18:48:19 +0000 (20:48 +0200)
committerMax Kellermann <max@duempel.org>
Fri, 9 Oct 2009 18:48:19 +0000 (20:48 +0200)
Combine all the checks in the two boolean variables "show_cursor" and
"selected".

src/list_window.c

index 92eaba5d0c6f05f72f63fb8a2e7fd12529cada2b..86da180ac56f493a02495719df5c09cb26cd1db2 100644 (file)
@@ -328,6 +328,9 @@ list_window_paint(struct list_window *lw,
                }
        }
 
+       show_cursor = show_cursor &&
+               (!options.hardware_cursor || lw->range_selection);
+
        for (i = 0; i < lw->rows; i++) {
                const char *label;
                char *second_column = NULL;
@@ -337,7 +340,9 @@ list_window_paint(struct list_window *lw,
                wmove(lw->w, i, 0);
 
                if (label) {
-                       bool selected = (lw->start + i >= lw->selected_start && lw->start + i <= lw->selected_end);
+                       bool selected = show_cursor &&
+                               lw->start + i >= lw->selected_start &&
+                               lw->start + i <= lw->selected_end;
                        unsigned len = utf8_width(label);
 
                        if (highlight)
@@ -345,8 +350,7 @@ list_window_paint(struct list_window *lw,
                        else
                                colors_use(lw->w, COLOR_LIST);
 
-                       if (show_cursor && selected &&
-                           (!options.hardware_cursor || lw->range_selection))
+                       if (selected)
                                wattron(lw->w, A_REVERSE);
 
                        //waddnstr(lw->w, label, lw->cols);