diff --git a/src/screen_help.c b/src/screen_help.c
index 0299d6ca418caaf1bb2407b33a04da3a1ca642e1..94fe9ab5b35dde881d27f40a08bb2102005a12f9 100644 (file)
--- a/src/screen_help.c
+++ b/src/screen_help.c
/*
- * (c) 2004 by Kalle Wallin (kaw@linux.se)
+ * $Id$
+ *
+ * (c) 2004 by Kalle Wallin <kaw@linux.se>
*
* 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
#include "config.h"
#include "ncmpc.h"
-#include "libmpdclient.h"
-#include "mpc.h"
+#include "mpdclient.h"
#include "command.h"
#include "screen.h"
#include "screen_utils.h"
-#include "screen_help.h"
typedef struct
{ 0, CMD_CLEAR, NULL },
{ 0, CMD_LIST_MOVE_UP, N_("Move song up") },
{ 0, CMD_LIST_MOVE_DOWN, N_("Move song down") },
+ { 0, CMD_ADD, NULL },
{ 0, CMD_SAVE_PLAYLIST, NULL },
{ 0, CMD_SCREEN_UPDATE, N_("Center") },
{ 0, CMD_TOGGLE_AUTOCENTER, NULL },
{ 0, CMD_DELETE, NULL },
{ 0, CMD_SCREEN_UPDATE, NULL },
- { 0, CMD_NONE, NULL },
- { 0, CMD_NONE, NULL },
- { 1, CMD_NONE, "ncmpc build information" },
- { 2, CMD_NONE, NULL },
- { 0, CMD_NONE, " Version : " VERSION },
- { 0, CMD_NONE, " Configuration dirs : ~/.ncmpc, " SYSCONFDIR "/" PACKAGE },
-#ifdef ENABLE_NLS
- { 0, CMD_NONE, "NLS support : yes" },
-#else
- { 0, CMD_NONE, "NLS support : no" },
-#endif
-#ifdef ENABLE_KEYDEF_SCREEN
- { 0, CMD_NONE, "Key Editor : yes" },
-#else
- { 0, CMD_NONE, "Key Editor : no" },
-#endif
-
{ 0, CMD_NONE, NULL },
{-1, CMD_NONE, NULL }
};
static char *
list_callback(int index, int *highlight, void *data)
{
- static char buf[256];
+ static char buf[512];
if( help_text_rows<0 )
{
if( help_text[index].command == CMD_NONE )
{
if( help_text[index].text )
- snprintf(buf, 256, "%28s", _(help_text[index].text));
+ g_snprintf(buf, sizeof(buf), "%28s", _(help_text[index].text));
else
if( help_text[index].highlight == 2 )
{
int i;
- for(i=3; i<COLS-3 && i<256; i++)
+ for(i=3; i<COLS-3 && i<sizeof(buf); i++)
buf[i]='-';
buf[i] = '\0';
}
else
- strcpy(buf, " ");
+ g_strlcpy(buf, " ", sizeof(buf));
return buf;
}
if( help_text[index].text )
- snprintf(buf, 256,
- "%20s : %s ",
- get_key_names(help_text[index].command, TRUE),
- _(help_text[index].text));
+ g_snprintf(buf, sizeof(buf),
+ "%20s : %s ",
+ get_key_names(help_text[index].command, TRUE),
+ _(help_text[index].text));
else
- snprintf(buf, 256,
- "%20s : %s ",
- get_key_names(help_text[index].command, TRUE),
- get_key_description(help_text[index].command));
+ g_snprintf(buf, sizeof(buf),
+ "%20s : %s ",
+ get_key_names(help_text[index].command, TRUE),
+ get_key_description(help_text[index].command));
return buf;
}
help_init(WINDOW *w, int cols, int rows)
{
lw = list_window_init(w, cols, rows);
+ lw->flags = LW_HIDE_CURSOR;
}
static void
static char *
-help_title(void)
+help_title(char *str, size_t size)
{
- return _("Music Player Client - Help");
+ return _("Help");
}
static void
-help_paint(screen_t *screen, mpd_client_t *c)
+help_paint(screen_t *screen, mpdclient_t *c)
{
lw->clear = 1;
list_window_paint(lw, list_callback, NULL);
}
static void
-help_update(screen_t *screen, mpd_client_t *c)
+help_update(screen_t *screen, mpdclient_t *c)
{
if( lw->repaint )
{
static int
-help_cmd(screen_t *screen, mpd_client_t *c, command_t cmd)
+help_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
{
- int retval;
+ lw->repaint=1;
+ switch(cmd)
+ {
+ case CMD_LIST_NEXT:
+ if( lw->start+lw->rows < help_text_rows )
+ lw->start++;
+ return 1;
+ case CMD_LIST_PREVIOUS:
+ if( lw->start >0 )
+ lw->start--;
+ return 1;
+ case CMD_LIST_FIRST:
+ lw->start = 0;
+ return 1;
+ case CMD_LIST_LAST:
+ lw->start = help_text_rows-lw->rows;
+ if( lw->start<0 )
+ lw->start = 0;
+ return 1;
+ case CMD_LIST_NEXT_PAGE:
+ lw->start = lw->start + lw->rows;
+ if( lw->start+lw->rows >= help_text_rows )
+ lw->start = help_text_rows-lw->rows;
+ if( lw->start<0 )
+ lw->start = 0;
+ return 1;
+ case CMD_LIST_PREVIOUS_PAGE:
+ lw->start = lw->start - lw->rows;
+ if( lw->start<0 )
+ lw->start = 0;
+ return 1;
+ default:
+ break;
+ }
- retval = list_window_cmd(lw, help_text_rows, cmd);
- if( !retval )
- return screen_find(screen, c,
- lw, help_text_rows,
- cmd, list_callback);
+ lw->selected = lw->start+lw->rows;
+ if( screen_find(screen, c,
+ lw, help_text_rows,
+ cmd, list_callback) )
+ {
+ /* center the row */
+ lw->start = lw->selected-(lw->rows/2);
+ if( lw->start+lw->rows > help_text_rows )
+ lw->start = help_text_rows-lw->rows;
+ if( lw->start<0 )
+ lw->start=0;
+ return 1;
+ }
- return retval;
+ return 0;
}
static list_window_t *