From ee182ced2b6cdd23bd54ff80baddbf6ed30a19e0 Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Fri, 19 Jun 2009 14:05:51 +0300 Subject: [PATCH] dump: Unify detection of fullwidth characters In DUMP_FUNCTION_SPECIALIZED (used by elinks --dump), detect the second cell of double-cell (aka fullwidth) characters by comparing to UCS_NO_CHAR, like add_document_to_string does. Don't use unicode_to_cell for this any more. Also, ignore the colors and attributes of the second cell; don't output any escape sequences for them. --- src/viewer/dump/dump-specialized.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/viewer/dump/dump-specialized.h b/src/viewer/dump/dump-specialized.h index c1e3433af..097d45490 100644 --- a/src/viewer/dump/dump-specialized.h +++ b/src/viewer/dump/dump-specialized.h @@ -80,6 +80,16 @@ DUMP_FUNCTION_SPECIALIZED(struct document *document, int fd, = &document->data[y].chars[x].color[3]; #endif /* DUMP_COLOR_MODE_TRUE */ + c = document->data[y].chars[x].data; + +#ifdef DUMP_CHARSET_UTF8 + if (c == UCS_NO_CHAR) { + /* This is the second cell of + * a double-cell character. */ + continue; + } +#endif /* DUMP_CHARSET_UTF8 */ + #ifdef DUMP_COLOR_MODE_16 if (color != color1) { color = color1; @@ -114,8 +124,6 @@ DUMP_FUNCTION_SPECIALIZED(struct document *document, int fd, } #endif /* DUMP_COLOR_MODE_TRUE */ - c = document->data[y].chars[x].data; - if ((attr & SCREEN_ATTR_FRAME) && c >= 176 && c < 224) c = frame_dumb[c - 176]; @@ -141,7 +149,6 @@ DUMP_FUNCTION_SPECIALIZED(struct document *document, int fd, fd, buf, &bptr)) return -1; } - x += unicode_to_cell(c) - 1; #else /* !DUMP_CHARSET_UTF8 */ if (write_char(c, fd, buf, &bptr)) return -1;