From 12dfc7fe9857debc553db236ef365d8695ad8f5a Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Sun, 15 Nov 2015 06:55:04 +0000 Subject: [PATCH] Backport r5370 from trunk. git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_2_4_branch@5418 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 6 ++++++ src/winio.c | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3489d720..f3bbd75e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2015-09-05 Benno Schulenberg + * src/winio.c (display_string, edit_draw): Force a redraw of a line + only when it contains a multicolumn character, to spare all regular + text this significant slowdown. This fixes Savannah bug #45684 + reported by Wyatt Ward. + 2015-08-14 Benno Schulenberg * src/help.c (help_line_len): The wrap location can be beyond the EOL, so for determining the length of the current line, don't start at that diff --git a/src/winio.c b/src/winio.c index af269010..523e3dbd 100644 --- a/src/winio.c +++ b/src/winio.c @@ -40,6 +40,8 @@ static int statusblank = 0; static bool disable_cursorpos = FALSE; /* Should we temporarily disable constant cursor position * display? */ +static bool seen_wide = FALSE; + /* Whether we've seen a multicolumn character in the current line. */ static sig_atomic_t sigwinch_counter_save = 0; @@ -1896,6 +1898,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool converted = charalloc(alloc_len); index = 0; + seen_wide = FALSE; if (buf[start_index] != '\0' && buf[start_index] != '\t' && (column < start_col || (dollars && column > 0))) { @@ -1939,6 +1942,9 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool while (buf[start_index] != '\0') { buf_mb_len = parse_mbchar(buf + start_index, buf_mb, NULL); + if (mbwidth(buf + start_index) > 1) + seen_wide = TRUE; + /* Make sure there's enough room for the next character, whether * it's a multibyte control character, a non-control multibyte * character, a tab character, or a null terminator. */ @@ -2473,7 +2479,8 @@ void edit_draw(filestruct *fileptr, const char *converted, int /* 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. */ - wredrawln(edit, line, 1); + if (seen_wide) + wredrawln(edit, line, 1); #endif #ifndef DISABLE_COLOR -- 2.39.5