prompt: trim a double-width character at the screen's edge

It needs to be trimmed and substituted with a single-width placeholder
to prevent the continuation character ">" from getting pushed to the
next row.

Also, use the correct width for the answer so that the continuation
character is only displayed when the answer does not fit any more.

This fixes https://savannah.gnu.org/bugs/?55620.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>

Original-patch-by: David Lawrence Ramsey <pooka109@gmail.com>
master
Benno Schulenberg 2019-02-06 14:51:53 +01:00
parent cf634d1aff
commit 5618189643
2 changed files with 5 additions and 3 deletions

View File

@ -395,11 +395,12 @@ void draw_the_promptbar(void)
waddch(bottomwin, ':');
waddch(bottomwin, (the_page == 0) ? ' ' : '<');
expanded = display_string(answer, the_page, COLS - base - 1, FALSE);
expanded = display_string(answer, the_page, COLS - base, FALSE);
waddstr(bottomwin, expanded);
free(expanded);
waddch(bottomwin, (the_page >= end_page) ? ' ' : '>');
if (base + strlenpt(answer) != COLS && the_page < end_page)
mvwaddch(bottomwin, 0, COLS - 1, '>');
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);

View File

@ -1988,7 +1988,8 @@ char *display_string(const char *buf, size_t column, size_t span, bool isdata)
}
/* If there is more text than can be shown, make room for the $ or >. */
if ((*buf != '\0' || column > beyond) && isdata && !ISSET(SOFTWRAP)) {
if ((*buf != '\0' || column > beyond) &&
(currmenu != MMAIN || (isdata && !ISSET(SOFTWRAP)))) {
index = move_mbleft(converted, index);
#ifdef ENABLE_UTF8