Code

screen_help: removed the help_text_row_t typedef
[ncmpc.git] / src / screen_help.c
index e967793a0dc874a186b4eab9127922d4a8fffe0a..1d83bf77c3ba106644b2447f19b36a37afcca086 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
+#include "screen_help.h"
+#include "screen_interface.h"
+#include "screen_find.h"
 #include "config.h"
 #include "i18n.h"
-#include "mpdclient.h"
-#include "command.h"
-#include "screen.h"
-#include "screen_utils.h"
 
-#include <stdlib.h>
-#include <string.h>
 #include <glib.h>
 
-typedef struct {
+#include <assert.h>
+
+struct help_text_row {
        signed char highlight;
        command_t command;
        const char *text;
-} help_text_row_t;
+};
 
-static help_text_row_t help_text[] = {
+static const struct help_text_row help_text[] = {
        { 1, CMD_NONE, N_("Movement") },
        { 2, CMD_NONE, NULL },
        { 0, CMD_LIST_PREVIOUS, NULL },
@@ -46,14 +45,16 @@ static help_text_row_t help_text[] = {
        { 0, CMD_LIST_NEXT_PAGE, NULL },
        { 0, CMD_LIST_FIRST, NULL },
        { 0, CMD_LIST_LAST, NULL },
-       { 0, CMD_LIST_VISUAL_SELECT, NULL },
+       { 0, CMD_LIST_RANGE_SELECT, NULL },
        { 0, CMD_LIST_SCROLL_UP_LINE, NULL},
        { 0, CMD_LIST_SCROLL_DOWN_LINE, NULL},
        { 0, CMD_LIST_SCROLL_UP_HALF, NULL},
        { 0, CMD_LIST_SCROLL_DOWN_HALF, NULL},
        { 0, CMD_NONE, NULL },
+
        { 0, CMD_SCREEN_PREVIOUS,NULL },
        { 0, CMD_SCREEN_NEXT, NULL },
+    { 0, CMD_SCREEN_SWAP, NULL },
        { 0, CMD_SCREEN_HELP, NULL },
        { 0, CMD_SCREEN_PLAY, NULL },
        { 0, CMD_SCREEN_FILE, NULL },
@@ -89,6 +90,8 @@ static help_text_row_t help_text[] = {
        { 0, CMD_NONE, NULL },
        { 0, CMD_REPEAT, NULL },
        { 0, CMD_RANDOM, NULL },
+       { 0, CMD_SINGLE, NULL },
+       { 0, CMD_CONSUME, NULL },
        { 0, CMD_CROSSFADE, NULL },
        { 0, CMD_SHUFFLE, NULL },
        { 0, CMD_DB_UPDATE, NULL },
@@ -116,6 +119,7 @@ static help_text_row_t help_text[] = {
        { 0, CMD_ADD, NULL },
        { 0, CMD_SAVE_PLAYLIST, NULL },
        { 0, CMD_SCREEN_UPDATE, N_("Center") },
+       { 0, CMD_SELECT_PLAYING, NULL },
        { 0, CMD_TOGGLE_AUTOCENTER, NULL },
 
        { 0, CMD_NONE, NULL },
@@ -150,6 +154,8 @@ static help_text_row_t help_text[] = {
        { 2, CMD_NONE, NULL },
        { 0, CMD_SCREEN_LYRICS, N_("View Lyrics") },
        { 0, CMD_SELECT, N_("(Re)load lyrics") },
+       /* to translators: this hotkey aborts the retrieval of lyrics
+          from the server */
        { 0, CMD_INTERRUPT, N_("Interrupt retrieval") },
        { 0, CMD_LYRICS_UPDATE, N_("Download lyrics for currently playing song") },
        { 0, CMD_SAVE_PLAYLIST, N_("Save lyrics") },
@@ -173,17 +179,14 @@ static help_text_row_t help_text[] = {
 #endif
 };
 
-#define help_text_rows (sizeof(help_text) / sizeof(help_text[0]))
-
-static list_window_t *lw;
+static struct list_window *lw;
 
 static const char *
-list_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED void *data)
+list_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED char** second_column, G_GNUC_UNUSED void *data)
 {
        static char buf[512];
 
-       if (idx >= help_text_rows)
-               return NULL;
+       assert(idx < G_N_ELEMENTS(help_text));
 
        if (help_text[idx].highlight)
                *highlight = true;
@@ -220,13 +223,13 @@ help_init(WINDOW *w, int cols, int rows)
 {
   lw = list_window_init(w, cols, rows);
        lw->hide_cursor = true;
+       list_window_set_length(lw, G_N_ELEMENTS(help_text));
 }
 
 static void
 help_resize(int cols, int rows)
 {
-  lw->cols = cols;
-  lw->rows = rows;
+       list_window_resize(lw, cols, rows);
 }
 
 static void
@@ -249,19 +252,18 @@ help_paint(void)
 }
 
 static bool
-help_cmd(G_GNUC_UNUSED mpdclient_t *c, command_t cmd)
+help_cmd(G_GNUC_UNUSED struct mpdclient *c, command_t cmd)
 {
-       if (list_window_scroll_cmd(lw, help_text_rows, cmd)) {
+       if (list_window_scroll_cmd(lw, cmd)) {
                list_window_paint(lw, list_callback, NULL);
                wrefresh(lw->w);
                return true;
        }
 
-       lw->selected = lw->start+lw->rows;
-       if (screen_find(lw,  help_text_rows,
-                       cmd, list_callback, NULL)) {
+       list_window_set_cursor(lw, lw->start);
+       if (screen_find(lw,  cmd, list_callback, NULL)) {
                /* center the row */
-               list_window_center(lw, help_text_rows, lw->selected);
+               list_window_center(lw, lw->selected);
                list_window_paint(lw, list_callback, NULL);
                wrefresh(lw->w);
                return true;