nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH] screen: include a workaround only when compiling ag


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH] screen: include a workaround only when compiling against older ncurses
Date: Sat, 16 Jul 2016 11:55:11 +0200

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

See https://savannah.gnu.org/bugs/?31743 for reference.
---
 src/nano.h  | 4 ++++
 src/winio.c | 9 +++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/nano.h b/src/nano.h
index 0937b8f..92e407e 100644
--- a/src/nano.h
+++ b/src/nano.h
@@ -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
diff --git a/src/winio.c b/src/winio.c
index e96f6e9..e46b1a6 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -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;
@@ -1753,7 +1755,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' &&
@@ -1837,9 +1841,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;
        }
 
@@ -2221,7 +2226,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. */
-- 
2.8.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]