tweaks: rename a function plus two parameters, to be more fitting

This commit is contained in:
Benno Schulenberg 2017-11-11 20:57:18 +01:00
parent a7f5907b43
commit 0c2b54a276
3 changed files with 19 additions and 20 deletions

View File

@ -700,20 +700,20 @@ int do_yesno_prompt(bool all, const char *msg)
/* Now show the ones for "Yes", "No", "Cancel" and maybe "All". */ /* Now show the ones for "Yes", "No", "Cancel" and maybe "All". */
sprintf(shortstr, " %c", yesstr[0]); sprintf(shortstr, " %c", yesstr[0]);
wmove(bottomwin, 1, 0); wmove(bottomwin, 1, 0);
onekey(shortstr, _("Yes"), width); post_one_key(shortstr, _("Yes"), width);
if (all) { if (all) {
shortstr[1] = allstr[0]; shortstr[1] = allstr[0];
wmove(bottomwin, 1, width); wmove(bottomwin, 1, width);
onekey(shortstr, _("All"), width); post_one_key(shortstr, _("All"), width);
} }
shortstr[1] = nostr[0]; shortstr[1] = nostr[0];
wmove(bottomwin, 2, 0); wmove(bottomwin, 2, 0);
onekey(shortstr, _("No"), width); post_one_key(shortstr, _("No"), width);
wmove(bottomwin, 2, 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. */ /* Color the statusbar over its full width and display the question. */

View File

@ -655,7 +655,7 @@ void statusbar(const char *msg);
void warn_and_shortly_pause(const char *msg); void warn_and_shortly_pause(const char *msg);
void statusline(message_type importance, const char *msg, ...); void statusline(message_type importance, const char *msg, ...);
void bottombars(int menu); 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 place_the_cursor(void);
void edit_draw(filestruct *fileptr, const char *converted, void edit_draw(filestruct *fileptr, const char *converted,
int line, size_t from_col); int line, size_t from_col);

View File

@ -2336,7 +2336,7 @@ void bottombars(int menu)
wmove(bottomwin, 1 + i % 2, (i / 2) * itemwidth); 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++; i++;
} }
@ -2345,25 +2345,24 @@ void bottombars(int menu)
wrefresh(bottomwin); wrefresh(bottomwin);
} }
/* Write a shortcut key to the help area at the bottom of the window. /* Write a key's representation plus a minute description of its function
* keystroke is e.g. "^G" and desc is e.g. "Get Help". We are careful * to the screen. For example, the key could be "^C" and its tag "Cancel".
* to write at most length characters, even if length is very small and * Key plus tag may occupy at most width columns. */
* keystroke and desc are long. Note that waddnstr(,,(size_t)-1) adds void post_one_key(const char *keystroke, const char *tag, int width)
* the whole string! We do not bother padding the entry with blanks. */
void onekey(const char *keystroke, const char *desc, int length)
{ {
wattron(bottomwin, interface_color_pair[KEY_COMBO]); 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]); 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, ' ');
waddch(bottomwin, ' '); wattron(bottomwin, interface_color_pair[FUNCTION_TAG]);
wattron(bottomwin, interface_color_pair[FUNCTION_TAG]); waddnstr(bottomwin, tag, actual_x(tag, width - 1));
waddnstr(bottomwin, desc, actual_x(desc, length)); wattroff(bottomwin, interface_color_pair[FUNCTION_TAG]);
wattroff(bottomwin, interface_color_pair[FUNCTION_TAG]);
}
} }
/* Redetermine current_y from the position of current relative to edittop, /* Redetermine current_y from the position of current relative to edittop,