tags 570630 + patch
thanks
I've got at patch that fixes this. Checking character width before adding it,
instead of after adding it, should allow trailing combining characters to be
added before advancing.
--
Theppitak Karoonboonyanan
http://linux.thai.net/~thep/
diff -ruN8p newt-0.52.10-old/textbox.c newt-0.52.10/textbox.c
--- newt-0.52.10-old/textbox.c 2010-02-20 21:22:43.000000000 +0700
+++ newt-0.52.10/textbox.c 2010-02-20 21:23:04.000000000 +0700
@@ -205,34 +205,36 @@ static void doReflow(const char * text,
fprintf(stderr,"adding %d\n",((width / 2) - (len)) / 2);
#endif
howbad += ((width / 2) - (len)) / 2;
}
text = end;
if (*text) text++;
} else {
const char *spcptr = NULL;
- int spc =0,w2, x;
+ int spc =0,w2, x, w;
chptr = text;
w2 = 0;
- for (i = 0; i < width - 1;) {
+ for (i = 0; ;) {
if ((x=mbrtowc(&tmp,chptr,end-chptr,&ps))<=0)
break;
+ w = wcwidth(tmp);
+ if (w>0)
+ i+=w;
+ if (i >= width)
+ break;
if (spc && !iswspace(tmp))
spc = 0;
else if (!spc && iswspace(tmp)) {
spc = 1;
spcptr = chptr;
w2 = i;
}
chptr += x;
- x = wcwidth(tmp);
- if (x>0)
- i+=x;
}
howbad += width - w2 + 1;
#ifdef DEBUG_WRAP
fprintf(stderr,"adding %d\n",width - w2 + 1, chptr);
#endif
if (spcptr) chptr = spcptr;
if (result) {
strncat(result, text, chptr - text );