diff --git a/src/screen_text.c b/src/screen_text.c
index 13bc58d6bc80018bcfab6e1dd36f5f733669d67c..21e73aac8ad47869bcbca505b7ea924ce3eac90f 100644 (file)
--- a/src/screen_text.c
+++ b/src/screen_text.c
-/*
- * (c) 2004-2008 The Music Player Daemon Project
- * http://www.musicpd.org/
+/* ncmpc (Ncurses MPD Client)
+ * (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
* it under the terms of the GNU General Public License as published by
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "screen_text.h"
-#include "screen_utils.h"
+#include "screen_find.h"
#include "charset.h"
#include <assert.h>
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
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,
- 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));
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;
}
- text->lw->selected = text->lw->start + text->lw->rows;
- if (screen_find(text->lw, text->lines->len,
- cmd, screen_text_list_callback, text)) {
+ list_window_set_cursor(text->lw, text->lw->start);
+ 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;
}