screen: include a workaround only when compiling against older ncurses

The bug with a leading wide character has been fixed since ncurses-5.9.

See https://savannah.gnu.org/bugs/?31743 for reference.
This commit is contained in:
Benno Schulenberg 2016-07-12 21:05:09 +02:00
parent 1c2d2a4027
commit 8c7a38596d
2 changed files with 11 additions and 2 deletions

View File

@ -92,6 +92,10 @@
#include <curses.h>
#endif /* CURSES_H */
#if defined(NCURSES_VERSION_MAJOR) && (NCURSES_VERSION_MAJOR < 6)
#define USING_OLD_NCURSES yes
#endif
#ifdef ENABLE_NLS
/* Native language support. */
#ifdef HAVE_LIBINTL_H

View File

@ -46,8 +46,10 @@ static int statusblank = 0;
/* The number of keystrokes left before we blank the statusbar. */
static bool suppress_cursorpos = FALSE;
/* Should we skip constant position display for one keystroke? */
#ifdef USING_OLD_NCURSES
static bool seen_wide = FALSE;
/* Whether we've seen a multicolumn character in the current line. */
#endif
#ifndef NANO_TINY
static sig_atomic_t last_sigwinch_counter = 0;
@ -1761,7 +1763,9 @@ char *display_string(const char *buf, size_t start_col, size_t span,
converted = charalloc(strlen(buf) * (mb_cur_max() + tabsize) + 1);
index = 0;
#ifdef USING_OLD_NCURSES
seen_wide = FALSE;
#endif
buf += start_index;
if (*buf != '\0' && *buf != '\t' &&
@ -1845,9 +1849,10 @@ char *display_string(const char *buf, size_t start_col, size_t span,
converted[index++] = *(buf++);
start_col += charwidth;
#ifdef USING_OLD_NCURSES
if (charwidth > 1)
seen_wide = TRUE;
#endif
continue;
}
@ -2229,7 +2234,7 @@ void edit_draw(filestruct *fileptr, const char *converted, int
* marking highlight on just the pieces that need it. */
mvwaddstr(edit, line, 0, converted);
#ifndef USE_SLANG
#ifdef USING_OLD_NCURSES
/* Tell ncurses to really redraw the line without trying to optimize
* for what it thinks is already there, because it gets it wrong in
* the case of a wide character in column zero. See bug #31743. */