From bdca00516ff158baff49114f0146455ea49d5564 Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Fri, 25 Nov 2016 17:31:18 -0700 Subject: * new color code had problems when TABs were present in text, since line length computation was not done correctly. The code also works for wide characters and control keys. --- pico/display.c | 43 +++++++++++++++++++++++++++++++++++++++---- pith/pine.hlp | 2 +- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/pico/display.c b/pico/display.c index aeceb1bb..ed9e7f80 100644 --- a/pico/display.c +++ b/pico/display.c @@ -302,7 +302,6 @@ vtputc(CELL c) vp->v_text[vtind-1] = ac; } else if (c.c == '\t') { - ac.c = ' '; do { vtputc(ac); } @@ -615,7 +614,25 @@ out: lp = lforw(lp); } vscreen[i]->v_flag |= (lp->l_sig ? VFSIG : 0)| VFCHG; - vscreen[i]->v_length = llength(lp); + /* compute physical length of line in screen */ + vscreen[i]->v_length = 0; + for (j = 0; vscreen[i]->v_length < term.t_ncol + && j < llength(lp); ++j){ + c = lgetc(lp, j); + if(c.c == '\t'){ + vscreen[i]->v_length |= 0x07; + vscreen[i]->v_length++; + } + else if(ISCONTROL(c.c)){ + vscreen[i]->v_length += 2; + } + else{ + int w; + + w = wcellwidth((UCS) c.c); + vscreen[i]->v_length += (w >= 0 ? w : 1); + } + } vtmove(i, 0); for (j = 0; j < llength(lp); ++j) @@ -625,7 +642,25 @@ out: else if ((wp->w_flag & (WFEDIT | WFHARD)) != 0){ while (i < wp->w_toprow+wp->w_ntrows){ vscreen[i]->v_flag |= (lp->l_sig ? VFSIG : 0 )| VFCHG; - vscreen[i]->v_length = llength(lp); + /* compute physical length of line in screen */ + vscreen[i]->v_length = 0; + for (j = 0; vscreen[i]->v_length < term.t_ncol + && j < llength(lp); ++j){ + c = lgetc(lp, j); + if(c.c == '\t'){ + vscreen[i]->v_length |= 0x07; + vscreen[i]->v_length++; + } + else if(ISCONTROL(c.c)){ + vscreen[i]->v_length += 2; + } + else{ + int w; + + w = wcellwidth((UCS) c.c); + vscreen[i]->v_length += (w >= 0 ? w : 1); + } + } vtmove(i, 0); /* if line has been changed */ @@ -1138,7 +1173,7 @@ updateline(int row, /* row on screen */ } } - if(pcolors && len < term.t_ncol) + if(row != 0 && pcolors && len < term.t_ncol) cp5 = cp1 + len; in_quote = 1; diff --git a/pith/pine.hlp b/pith/pine.hlp index a76e024b..a3936146 100644 --- a/pith/pine.hlp +++ b/pith/pine.hlp @@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any reasonable place to be called from. Dummy change to get revision in pine.hlp ============= h_revision ================= -Alpine Commit 186 2016-11-23 08:07:37 +Alpine Commit 187 2016-11-25 17:31:13 ============= h_news ================= -- cgit v1.2.3-70-g09d2