X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fscreen_help.c;h=94fe9ab5b35dde881d27f40a08bb2102005a12f9;hb=9a500d13055f16b70796a5fce5ec6de4a2844187;hp=0299d6ca418caaf1bb2407b33a04da3a1ca642e1;hpb=77c69999a63e6b999814cb39c35bb4d30646c145;p=ncmpc.git diff --git a/src/screen_help.c b/src/screen_help.c index 0299d6c..94fe9ab 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -1,5 +1,7 @@ /* - * (c) 2004 by Kalle Wallin (kaw@linux.se) + * $Id$ + * + * (c) 2004 by Kalle Wallin * * 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 @@ -23,12 +25,10 @@ #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 @@ -96,6 +96,7 @@ static help_text_row_t help_text[] = { 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 }, @@ -109,23 +110,6 @@ static help_text_row_t help_text[] = { 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 } }; @@ -137,7 +121,7 @@ static list_window_t *lw = NULL; static char * list_callback(int index, int *highlight, void *data) { - static char buf[256]; + static char buf[512]; if( help_text_rows<0 ) { @@ -153,30 +137,30 @@ list_callback(int index, int *highlight, void *data) 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; iflags = LW_HIDE_CURSOR; } static void @@ -204,13 +189,13 @@ help_exit(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); @@ -218,7 +203,7 @@ help_paint(screen_t *screen, mpd_client_t *c) } static void -help_update(screen_t *screen, mpd_client_t *c) +help_update(screen_t *screen, mpdclient_t *c) { if( lw->repaint ) { @@ -230,17 +215,58 @@ help_update(screen_t *screen, mpd_client_t *c) 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 *