From 0c2b54a276ff6e692867023ea3f78e054f5b02ac Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 11 Nov 2017 20:57:18 +0100 Subject: [PATCH] tweaks: rename a function plus two parameters, to be more fitting --- src/prompt.c | 8 ++++---- src/proto.h | 2 +- src/winio.c | 29 ++++++++++++++--------------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/prompt.c b/src/prompt.c index 3df68fbd..dec6692c 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -700,20 +700,20 @@ int do_yesno_prompt(bool all, const char *msg) /* Now show the ones for "Yes", "No", "Cancel" and maybe "All". */ sprintf(shortstr, " %c", yesstr[0]); wmove(bottomwin, 1, 0); - onekey(shortstr, _("Yes"), width); + post_one_key(shortstr, _("Yes"), width); if (all) { shortstr[1] = allstr[0]; wmove(bottomwin, 1, width); - onekey(shortstr, _("All"), width); + post_one_key(shortstr, _("All"), width); } shortstr[1] = nostr[0]; wmove(bottomwin, 2, 0); - onekey(shortstr, _("No"), width); + post_one_key(shortstr, _("No"), width); wmove(bottomwin, 2, width); - onekey("^C", _("Cancel"), width); + post_one_key("^C", _("Cancel"), width); } /* Color the statusbar over its full width and display the question. */ diff --git a/src/proto.h b/src/proto.h index 5843cf53..48ee525a 100644 --- a/src/proto.h +++ b/src/proto.h @@ -655,7 +655,7 @@ void statusbar(const char *msg); void warn_and_shortly_pause(const char *msg); void statusline(message_type importance, const char *msg, ...); void bottombars(int menu); -void onekey(const char *keystroke, const char *desc, int length); +void post_one_key(const char *keystroke, const char *tag, int width); void place_the_cursor(void); void edit_draw(filestruct *fileptr, const char *converted, int line, size_t from_col); diff --git a/src/winio.c b/src/winio.c index 215adf2d..bcabdfd4 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2336,7 +2336,7 @@ void bottombars(int menu) wmove(bottomwin, 1 + i % 2, (i / 2) * itemwidth); - onekey(s->keystr, _(f->desc), itemwidth + (COLS % itemwidth)); + post_one_key(s->keystr, _(f->desc), itemwidth + (COLS % itemwidth)); i++; } @@ -2345,25 +2345,24 @@ void bottombars(int menu) wrefresh(bottomwin); } -/* Write a shortcut key to the help area at the bottom of the window. - * keystroke is e.g. "^G" and desc is e.g. "Get Help". We are careful - * to write at most length characters, even if length is very small and - * keystroke and desc are long. Note that waddnstr(,,(size_t)-1) adds - * the whole string! We do not bother padding the entry with blanks. */ -void onekey(const char *keystroke, const char *desc, int length) +/* Write a key's representation plus a minute description of its function + * to the screen. For example, the key could be "^C" and its tag "Cancel". + * Key plus tag may occupy at most width columns. */ +void post_one_key(const char *keystroke, const char *tag, int width) { wattron(bottomwin, interface_color_pair[KEY_COMBO]); - waddnstr(bottomwin, keystroke, actual_x(keystroke, length)); + waddnstr(bottomwin, keystroke, actual_x(keystroke, width)); wattroff(bottomwin, interface_color_pair[KEY_COMBO]); - length -= strlenpt(keystroke) + 1; + /* If the remaning space is too small, skip the description. */ + width -= strlenpt(keystroke); + if (width < 2) + return; - if (length > 0) { - waddch(bottomwin, ' '); - wattron(bottomwin, interface_color_pair[FUNCTION_TAG]); - waddnstr(bottomwin, desc, actual_x(desc, length)); - wattroff(bottomwin, interface_color_pair[FUNCTION_TAG]); - } + waddch(bottomwin, ' '); + wattron(bottomwin, interface_color_pair[FUNCTION_TAG]); + waddnstr(bottomwin, tag, actual_x(tag, width - 1)); + wattroff(bottomwin, interface_color_pair[FUNCTION_TAG]); } /* Redetermine current_y from the position of current relative to edittop,