X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fscreen_help.c;h=94fe9ab5b35dde881d27f40a08bb2102005a12f9;hb=9a500d13055f16b70796a5fce5ec6de4a2844187;hp=4d76ffe7fa3b6414d90061cb135827a4a6c9684b;hpb=fc0fe1147f7f69d3d181eb254fd6e23991aa5b20;p=ncmpc.git diff --git a/src/screen_help.c b/src/screen_help.c index 4d76ffe..94fe9ab 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -110,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 } }; @@ -138,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 ) { @@ -154,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 @@ -233,15 +217,56 @@ help_update(screen_t *screen, mpdclient_t *c) static int 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 *