Code

list_window: fully disable highlighting code on --enable-mini
[ncmpc.git] / src / list_window.c
index f3251d3ceaf9657292aa5bf56b817202cf22324f..10e06292ad605719ff677f75b9f76d9646689d7e 100644 (file)
@@ -378,6 +378,7 @@ list_window_paint_row(WINDOW *w, unsigned y, unsigned width,
 
 #ifdef NCMPC_MINI
        second_column = NULL;
+       highlight = false;
 #endif /* NCMPC_MINI */
 
        if (second_column != NULL) {
@@ -429,15 +430,14 @@ list_window_paint(const struct list_window *lw,
 {
        unsigned i;
        bool show_cursor = !lw->hide_cursor;
-       bool highlight = false;
 
        show_cursor = show_cursor &&
                (!options.hardware_cursor || lw->range_selection);
 
        for (i = 0; i < lw->rows; i++) {
                const char *label;
+               bool highlight = false;
                char *second_column = NULL;
-               highlight = false;
 
                wmove(lw->w, i, 0);
 
@@ -449,6 +449,11 @@ list_window_paint(const struct list_window *lw,
                label = callback(lw->start + i, &highlight, &second_column, callback_data);
                assert(label != NULL);
 
+#ifdef NCMPC_MINI
+               highlight = false;
+               second_column = NULL;
+#endif /* NCMPC_MINI */
+
                list_window_paint_row(lw->w, i, lw->cols,
                                      show_cursor &&
                                      lw->start + i >= lw->selected_start &&
@@ -548,6 +553,23 @@ list_window_rfind(struct list_window *lw,
        return false;
 }
 
+static bool
+jump_match(const char *haystack, const char *needle)
+{
+#ifdef NCMPC_MINI
+       bool jump_prefix_only = true;
+#else
+       bool jump_prefix_only = options.jump_prefix_only;
+#endif
+
+       assert(haystack != NULL);
+       assert(needle != NULL);
+
+       return jump_prefix_only
+               ? g_ascii_strncasecmp(haystack, needle, strlen(needle)) == 0
+               : match_line(haystack, needle);
+}
+
 bool
 list_window_jump(struct list_window *lw,
                 list_window_callback_fn_t callback,
@@ -565,13 +587,8 @@ list_window_jump(struct list_window *lw,
 
                if (label[0] == '[')
                        label++;
-#ifndef NCMPC_MINI
-               if ((options.jump_prefix_only && g_ascii_strncasecmp(label, str, strlen(str)) == 0) ||
-                    (!options.jump_prefix_only && match_line(label, str)))
-#else
-               if (g_ascii_strncasecmp(label, str, strlen(str)) == 0)
-#endif
-               {
+
+               if (jump_match(label, str)) {
                        list_window_move_cursor(lw, i);
                        return true;
                }