Code

screen_help: simplify the list_window callback
authorMax Kellermann <max@duempel.org>
Sun, 11 Oct 2009 17:30:20 +0000 (19:30 +0200)
committerMax Kellermann <max@duempel.org>
Sun, 11 Oct 2009 17:30:20 +0000 (19:30 +0200)
Return unmodified strings.  Since that callback isn't used for
painting, we don't need to consider the layout here.

src/screen_help.c

index 2a9b72ab4fee3c1d4719ce8f0091a0e9a8ba6c66..1a66b698fbf7915eeb9ed12a26271b9dd18776b4 100644 (file)
@@ -184,40 +184,21 @@ static const struct help_text_row help_text[] = {
 static struct list_window *lw;
 
 static const char *
-list_callback(unsigned idx, bool *highlight, G_GNUC_UNUSED char** second_column, G_GNUC_UNUSED void *data)
+list_callback(unsigned i,
+             G_GNUC_UNUSED bool *highlight, G_GNUC_UNUSED char** second_column,
+             G_GNUC_UNUSED void *data)
 {
-       static char buf[512];
-
-       assert(idx < G_N_ELEMENTS(help_text));
+       const struct help_text_row *row = &help_text[i];
 
-       if (help_text[idx].highlight)
-               *highlight = true;
+       assert(i < G_N_ELEMENTS(help_text));
 
-       if (help_text[idx].command == CMD_NONE) {
-               if (help_text[idx].text)
-                       g_snprintf(buf, sizeof(buf), "      %s", _(help_text[idx].text));
-               else if (help_text[idx].highlight == 2) {
-                       int i;
+       if (row->text != NULL)
+               return _(row->text);
 
-                       for (i = 3; i < COLS - 3 && i < (int)sizeof(buf); i++)
-                               buf[i] = '-';
-                       buf[i] = '\0';
-               } else
-                       g_strlcpy(buf, " ", sizeof(buf));
-               return buf;
-       }
+       if (row->command != CMD_NONE)
+               return get_key_description(row->command);
 
-       if (help_text[idx].text)
-               g_snprintf(buf, sizeof(buf),
-                          "%20s : %s   ",
-                          get_key_names(help_text[idx].command, TRUE),
-                          _(help_text[idx].text));
-       else
-               g_snprintf(buf, sizeof(buf),
-                          "%20s : %s   ",
-                          get_key_names(help_text[idx].command, TRUE),
-                          get_key_description(help_text[idx].command));
-       return buf;
+       return "";
 }
 
 static void