mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
uniblock demo: simplify, maaaaaaaan
This commit is contained in:
parent
5ff84cb9dd
commit
35bda058b0
@ -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…
Reference in New Issue
Block a user