uc_is_grapheme_break() ought be evaluated across the EGC #2364

This commit is contained in:
nick black 2021-11-22 11:29:30 -03:00
parent 6f4f0f741a
commit f061e1550a
3 changed files with 9 additions and 10 deletions

View File

@ -247,15 +247,10 @@ dostring(struct ncplane* n, const char** s, uint32_t rgb,
continue;
}
size_t ulen = 0;
int r;
if(wcwidth(wcs) <= (int)(maxx - x)){
if((r = ncplane_putegc(n, &(*s)[idx], &ulen)) <= 0){
return -1;
}
}else{
if((r = ncplane_putchar(n, '#')) < 1){
return -1;
}
int r = 0;
int w;
if((r = ncplane_putegc(n, &(*s)[idx], &ulen)) <= 0){
return 0;
}
ncplane_cursor_yx(n, &y, &x);
idx += ulen;
@ -406,6 +401,7 @@ int witherworm_demo(struct notcurses* nc){
"Jeg kan spise glas, det gør ikke ondt på mig",
"㎚㎛㎜㎝㎞㎟㎠㎡㎢㎣㎤㎥㎦㎕㎖㎗㎘㏄㎰㎱㎲㎳㎍㎎㎏㎅㎆㏔㎇㎐㎑㎒㎓㎔㎮㎯",
"Æ ka æe glass uhen at det go mæ naue",
// FIXME this one
"က္ယ္ဝန္တော္၊က္ယ္ဝန္မ မ္ယက္စားနုိင္သည္။ ၎က္ရောင္ ထိခုိက္မ္ဟု မရ္ဟိပာ။",
"ကျွန်တော် ကျွန်မ မှန်စားနိုင်တယ်။ ၎င်းကြောင့် ထိခိုက်မှုမရှိပါ။ ",
"Tôi có thể ăn thủy tinh mà không hại gì",

View File

@ -136,7 +136,9 @@ utf8_egc_len(const char* gcluster, int* colcount){
}
ret += r;
gcluster += r;
prevw = wc;
if(!prevw){
prevw = wc;
}
}while(r);
// FIXME what if injoin is set? incomplete EGC!
return ret;

View File

@ -1752,6 +1752,7 @@ int ncplane_putc_yx(ncplane* n, int y, int x, const nccell* c){
int ncplane_putegc_yx(ncplane* n, int y, int x, const char* gclust, size_t* sbytes){
int cols;
int bytes = utf8_egc_len(gclust, &cols);
fprintf(stderr, "BYTES: %d COLS: %d [%s]\n", bytes, cols, gclust);
if(bytes < 0){
return -1;
}