Code

screen_lyrics: optionally show the plugin used
[ncmpc.git] / src / screen_text.c
index 56e41d3e07bba2b60cb565ca62f0b06f8882eb77..617d38e2b592d0cf27653f09f651d667fd4f8564 100644 (file)
@@ -1,5 +1,5 @@
 /* ncmpc (Ncurses MPD Client)
- * (c) 2004-2009 The Music Player Daemon Project
+ * (c) 2004-2010 The Music Player Daemon Project
  * Project homepage: http://musicpd.org
 
  * This program is free software; you can redistribute it and/or modify
@@ -33,6 +33,7 @@ screen_text_clear(struct screen_text *text)
                g_free(g_ptr_array_index(text->lines, i));
 
        g_ptr_array_set_size(text->lines, 0);
+       list_window_set_length(text->lw, 0);
 }
 
 void
@@ -74,18 +75,18 @@ screen_text_set(struct screen_text *text, const GString *str)
 
        if (*p != 0)
                g_ptr_array_add(text->lines, g_strdup(p));
+
+       list_window_set_length(text->lw, text->lines->len);
 }
 
 const char *
-screen_text_list_callback(unsigned idx, G_GNUC_UNUSED bool *highlight,
-                         G_GNUC_UNUSED char** sc, void *data)
+screen_text_list_callback(unsigned idx, void *data)
 {
        const struct screen_text *text = data;
        static char buffer[256];
        char *value;
 
-       if (idx >= text->lines->len)
-               return NULL;
+       assert(idx < text->lines->len);
 
        value = utf8_to_locale(g_ptr_array_index(text->lines, idx));
        g_strlcpy(buffer, value, sizeof(buffer));
@@ -98,17 +99,15 @@ bool
 screen_text_cmd(struct screen_text *text,
                G_GNUC_UNUSED struct mpdclient *c, command_t cmd)
 {
-       if (list_window_scroll_cmd(text->lw, text->lines->len, cmd)) {
+       if (list_window_scroll_cmd(text->lw, cmd)) {
                screen_text_repaint(text);
                return true;
        }
 
        list_window_set_cursor(text->lw, text->lw->start);
-       if (screen_find(text->lw, text->lines->len,
-                       cmd, screen_text_list_callback, text)) {
+       if (screen_find(text->lw, cmd, screen_text_list_callback, text)) {
                /* center the row */
-               list_window_center(text->lw, text->lines->len,
-                                  text->lw->selected);
+               list_window_center(text->lw, text->lw->selected);
                screen_text_repaint(text);
                return true;
        }