help: allow the penultimate item extra space when the number is uneven

This avoids unnecessarily truncating the last help item on the
very bottom row when there is still plenty of room.

This fixes https://savannah.gnu.org/bugs/?59550.

Bug has been visible since at least version 2.5.1.
This commit is contained in:
Benno Schulenberg 2020-11-26 17:12:09 +01:00
parent 13b839734f
commit 29276d1d3a

View File

@ -2216,6 +2216,8 @@ void bottombars(int menu)
/* Display the first number of shortcuts in the given menu that
* have a key combination assigned to them. */
for (f = allfuncs, index = 0; f != NULL && index < number; f = f->next) {
size_t thiswidth = itemwidth;
if ((f->menus & menu) == 0)
continue;
@ -2226,7 +2228,11 @@ void bottombars(int menu)
wmove(bottomwin, 1 + index % 2, (index / 2) * itemwidth);
post_one_key(s->keystr, _(f->desc), itemwidth +
/* When the number is uneven, the penultimate item can be extra wide. */
if ((number % 2) == 1 && (index + 2 == number))
thiswidth += itemwidth;
post_one_key(s->keystr, _(f->desc), thiswidth +
((index < number - 2) ? 0 : COLS % itemwidth));
index++;
}