help: don't waste the last column in the help viewer on narrow terminals

When a line in a help text is wider than the terminal, then do not break
that line at COLS - 1, but simply at COLS.  In olden times it made some
sense to have an empty column on the right of the introductory text, to
mirror the one on the left.  But since the width of the introductions
got limited to 74 columns (four years ago, in commit a9aa0ef9), those
texts have (on a default 80-column terminal) at least six empty columns
on their righthand side.  And on narrower terminals, we really don't
want to waste anything and should use all available space.

Also, this whole mechanism of making an exception for end-of-string or
end-of-paragraph and letting only those make use of the final column,
it was a waste of time: it kind-of did the whole break_line() process
again, but then for the entire string (which can be some five hundred
characters long in the introductory texts).  So... get rid of it, make
it simple.  On an 80-column terminal it doesn't make any difference.
master
Benno Schulenberg 2019-12-22 19:27:48 +01:00
parent 074cf40409
commit dda1b167c9
1 changed files with 2 additions and 17 deletions

View File

@ -576,28 +576,13 @@ functionptrtype parse_help_input(int *kbinput)
/* Calculate the displayable length of the help-text line starting at ptr. */
size_t help_line_len(const char *ptr)
{
size_t wrapping_point = (COLS > 24) ? COLS - 1 : 24;
/* The target width for wrapping long lines. */
ssize_t wrap_location;
/* Actual position where the line can be wrapped. */
size_t length = 0;
/* Full length of the line, until the first newline. */
size_t wrapping_point = (COLS < 24) ? 24 : COLS;
/* Avoid overwide paragraphs in the introductory text. */
if (ptr < end_of_intro && COLS > 74)
wrapping_point = 74;
wrap_location = break_line(ptr, wrapping_point, TRUE);
/* Get the length of the entire line up to a null or a newline. */
while (*(ptr + length) != '\0' && *(ptr + length) != '\n')
length = step_right(ptr, length);
/* If the entire line will just fit the screen, don't wrap it. */
if (wideness(ptr, length) <= wrapping_point + 1)
return length;
else
return wrap_location;
return break_line(ptr, wrapping_point, TRUE);
}
#endif /* ENABLE_HELP */