uniblock demo: simplify, maaaaaaaan

pull/677/head
nick black 4 years ago
parent 5ff84cb9dd
commit 35bda058b0
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -58,20 +58,19 @@ draw_block(struct ncplane* nn, uint32_t blockstart){
for(chunk = 0 ; chunk < BLOCKSIZE / CHUNKSIZE ; ++chunk){
int z;
for(z = 0 ; z < CHUNKSIZE ; ++z){
wchar_t w[2] = { blockstart + chunk * CHUNKSIZE + z, L'\0' };
wchar_t w = blockstart + chunk * CHUNKSIZE + z;
char utf8arr[MB_CUR_MAX * 3 + 5];
if(wcswidth(w, INT_MAX) >= 1 && iswgraph(w[0])){
if(wcwidth(w) >= 1 && iswgraph(w)){
mbstate_t ps;
memset(&ps, 0, sizeof(ps));
const wchar_t *wptr = w;
int bwc = wcsrtombs(utf8arr, &wptr, sizeof(utf8arr), &ps);
int bwc = wcrtomb(utf8arr, w, &ps);
if(bwc < 0){
fprintf(stderr, "Couldn't convert %u (%x) (%lc) (%s)\n",
blockstart + chunk * CHUNKSIZE + z,
blockstart + chunk * CHUNKSIZE + z, w[0], strerror(errno));
blockstart + chunk * CHUNKSIZE + z, w, strerror(errno));
return -1;
}
if(wcwidth(w[0]) < 2){
if(wcwidth(w) < 2){
utf8arr[bwc++] = ' ';
}
utf8arr[bwc++] = 0xe2;

Loading…
Cancel
Save