From 9c5a796af1c71429aa4cc5d6deb635f804ec8d07 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 11 Oct 2009 19:30:20 +0200 Subject: [PATCH] screen_help: simplify the list_window callback Return unmodified strings. Since that callback isn't used for painting, we don't need to consider the layout here. --- src/screen_help.c | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/src/screen_help.c b/src/screen_help.c index 2a9b72a..1a66b69 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -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 -- 2.30.2