From 6b90fee5129ec8d8f1842c330d73497ba73ea25c Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Sun, 10 Feb 2013 14:13:36 +0330 Subject: [PATCH] term: handle fullwidth chars in the last column This handles wrapping double-width characters when inserted in the last column of the screen. Felix Janda reported this case and prepared a preliminary patch. Handling fullwidth characters was originally suggested by Sara Fauzia which resulted in a simple patch to simply ignore these characters in the bold branch. A recent request and patch from Felix Janda motivated me to apply a modified version to the master branch. --- term.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/term.c b/term.c index 34583bb..c87f98a 100644 --- a/term.c +++ b/term.c @@ -523,7 +523,7 @@ static void kill_chars(int sc, int ec) { int i; for (i = sc; i < ec; i++) - draw_char(' ', row, i); + draw_char(0, row, i); draw_cursor(1); } @@ -573,16 +573,15 @@ static void advance(int dr, int dc, int scrl) static void insertchar(int c) { - int wrapready; if (mode & MODE_WRAPREADY) advance(1, -col, 1); if (mode & MODE_INSERT) insert_chars(1); draw_char(c, row, col); - wrapready = col == pad_cols() - 1; - advance(0, 1, 1); - if (wrapready) + if (col == pad_cols() - 1) mode = BIT_SET(mode, MODE_WRAPREADY, 1); + else + advance(0, 1, 1); } @@ -655,6 +654,8 @@ static void ctlseq(void) break; default: c = readutf8(c); + if (isdw(c) && col + 1 == pad_cols() && ~mode & MODE_WRAPREADY) + insertchar(0); if (!iszw(c)) insertchar(c); if (isdw(c)) -- 2.11.4.GIT