|
|
@ -10,6 +10,13 @@
|
|
|
|
#define BLOCKSIZE 512 // show this many per page
|
|
|
|
#define BLOCKSIZE 512 // show this many per page
|
|
|
|
#define CHUNKSIZE 32 // show this many per line
|
|
|
|
#define CHUNKSIZE 32 // show this many per line
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
|
|
|
fade_block(struct ncplane* nn, const struct timespec* subdelay){
|
|
|
|
|
|
|
|
int ret = ncplane_fadein(nn, subdelay, NULL);
|
|
|
|
|
|
|
|
ncplane_destroy(nn);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
static int
|
|
|
|
draw_block(struct ncplane* nn, uint32_t blockstart){
|
|
|
|
draw_block(struct ncplane* nn, uint32_t blockstart){
|
|
|
|
cell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER;
|
|
|
|
cell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER;
|
|
|
@ -41,12 +48,11 @@ draw_block(struct ncplane* nn, uint32_t blockstart){
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int z;
|
|
|
|
int z;
|
|
|
|
cell c = CELL_TRIVIAL_INITIALIZER;
|
|
|
|
|
|
|
|
// 16 to a line
|
|
|
|
// 16 to a line
|
|
|
|
for(z = 0 ; z < CHUNKSIZE ; ++z){
|
|
|
|
for(z = 0 ; z < CHUNKSIZE ; ++z){
|
|
|
|
wchar_t w[2] = { blockstart + chunk * CHUNKSIZE + z, L'\u200e' };
|
|
|
|
wchar_t w[3] = { blockstart + chunk * CHUNKSIZE + z, L'\u200e', L'\0' };
|
|
|
|
char utf8arr[MB_CUR_MAX * 2 + 1];
|
|
|
|
char utf8arr[MB_CUR_MAX * 2 + 1];
|
|
|
|
if(wcswidth(w, 2) >= 1 && iswprint(w[0])){
|
|
|
|
if(wcswidth(w, 3) >= 1 && iswprint(w[0])){
|
|
|
|
mbstate_t ps;
|
|
|
|
mbstate_t ps;
|
|
|
|
memset(&ps, 0, sizeof(ps));
|
|
|
|
memset(&ps, 0, sizeof(ps));
|
|
|
|
const wchar_t *wptr = w;
|
|
|
|
const wchar_t *wptr = w;
|
|
|
@ -61,8 +67,8 @@ draw_block(struct ncplane* nn, uint32_t blockstart){
|
|
|
|
}else{ // don't dump non-printing codepoints
|
|
|
|
}else{ // don't dump non-printing codepoints
|
|
|
|
strcpy(utf8arr, " ");
|
|
|
|
strcpy(utf8arr, " ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cell_set_fg_rgb(&c, 0xad + z * 2, 0xd8, 0xe6 - z * 2);
|
|
|
|
ncplane_set_fg_rgb(nn, 0xad + z * 2, 0xd8, 0xe6 - z * 2);
|
|
|
|
cell_set_bg_rgb(&c, 8 * chunk, 8 * chunk + z, 8 * chunk);
|
|
|
|
ncplane_set_bg_rgb(nn, 8 * chunk, 8 * chunk + z, 8 * chunk);
|
|
|
|
if(ncplane_putstr(nn, utf8arr) < 0){
|
|
|
|
if(ncplane_putstr(nn, utf8arr) < 0){
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -72,7 +78,6 @@ draw_block(struct ncplane* nn, uint32_t blockstart){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cell_release(nn, &c);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -187,9 +192,9 @@ int unicodeblocks_demo(struct notcurses* nc){
|
|
|
|
if(ncplane_printf_aligned(n, 6 + BLOCKSIZE / CHUNKSIZE, NCALIGN_CENTER, "%s", description) <= 0){
|
|
|
|
if(ncplane_printf_aligned(n, 6 + BLOCKSIZE / CHUNKSIZE, NCALIGN_CENTER, "%s", description) <= 0){
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notcurses_render(nc);
|
|
|
|
if(fade_block(nn, &subdelay)){ // destroys nn
|
|
|
|
nanosleep(&subdelay, NULL);
|
|
|
|
return -1;
|
|
|
|
ncplane_destroy(nn);
|
|
|
|
}
|
|
|
|
// for a 32-bit wchar_t, we would want up through 24 bits of block ID. but
|
|
|
|
// for a 32-bit wchar_t, we would want up through 24 bits of block ID. but
|
|
|
|
// really, the vast majority of space is unused.
|
|
|
|
// really, the vast majority of space is unused.
|
|
|
|
blockstart += BLOCKSIZE;
|
|
|
|
blockstart += BLOCKSIZE;
|
|
|
|