From 954d04bc5961afb390326333f0bc35b1e99884a5 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sat, 5 Sep 2015 09:14:24 +0000 Subject: [PATCH] Forcing a redraw of a line only when it contains a multicolumn character, as that is the only known situation where things go wrong. This spares all regular text a significant slowdown. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5370 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 76309864..983bbe70 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-09-04 Benno Schulenberg * src/chars.c: Reverting r5354 from August 12. This fixes Savannah bug #45874. Apparently there is /some/ state somewhere after all. diff --git a/src/winio.c b/src/winio.c index 32f9921b..b3a9da2e 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. */ @@ -2472,7 +2478,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