From f061e1550abc818b72591fe932777e81204a16f7 Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 22 Nov 2021 11:29:30 -0300 Subject: [PATCH] uc_is_grapheme_break() ought be evaluated across the EGC #2364 --- src/demo/whiteout.c | 14 +++++--------- src/lib/egcpool.h | 4 +++- src/lib/notcurses.c | 1 + 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/demo/whiteout.c b/src/demo/whiteout.c index aee6a8d61..aedad7d92 100644 --- a/src/demo/whiteout.c +++ b/src/demo/whiteout.c @@ -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ì", diff --git a/src/lib/egcpool.h b/src/lib/egcpool.h index 68b333c45..9589a2677 100644 --- a/src/lib/egcpool.h +++ b/src/lib/egcpool.h @@ -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; diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 4d00191a1..72bba9919 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -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; }