|
|
|
@ -7,7 +7,6 @@
|
|
|
|
|
#include "demo.h"
|
|
|
|
|
|
|
|
|
|
// show unicode blocks. a block is always a multiple of 16 codepoints.
|
|
|
|
|
#define ITERATIONS 24 // show this many pages
|
|
|
|
|
#define BLOCKSIZE 512 // show this many per page
|
|
|
|
|
#define CHUNKSIZE 32 // show this many per line
|
|
|
|
|
|
|
|
|
@ -15,11 +14,43 @@ int unicodeblocks_demo(struct notcurses* nc){
|
|
|
|
|
struct ncplane* n = notcurses_stdplane(nc);
|
|
|
|
|
int maxx, maxy;
|
|
|
|
|
notcurses_term_dimyx(nc, &maxy, &maxx);
|
|
|
|
|
int i;
|
|
|
|
|
// show 256 at a time. start with the known-working ascii/latin-1 blocks.
|
|
|
|
|
uint32_t blockstart = 0;
|
|
|
|
|
for(i = 0 ; i < ITERATIONS ; ++i){
|
|
|
|
|
// some blocks are good for the printing, some less so. some are only
|
|
|
|
|
// marginally covered by mainstream fonts, some not at all. we explicitly
|
|
|
|
|
// list the ones we want.
|
|
|
|
|
const struct {
|
|
|
|
|
const char* name;
|
|
|
|
|
uint32_t start;
|
|
|
|
|
} blocks[] = {
|
|
|
|
|
{ .name = "Basic Latin, Latin 1 Supplement, Latin Extended", .start = 0, },
|
|
|
|
|
{ .name = "IPA Extensions, Spacing Modifiers, Greek and Coptic", .start = 0x200, },
|
|
|
|
|
{ .name = "Cyrillic, Cyrillic Supplement, Armenian, Hebrew", .start = 0x400, },
|
|
|
|
|
{ .name = "Arabic, Syriac, Arabic Supplement", .start = 0x600, },
|
|
|
|
|
{ .name = "Samaritan, Mandaic, Devanagari, Bengali", .start = 0x800, },
|
|
|
|
|
{ .name = "Gurmukhi, Gujarati, Oriya, Tamil", .start = 0xa00, },
|
|
|
|
|
{ .name = "Telugu, Kannada, Malayalam, Sinhala", .start = 0xc00, },
|
|
|
|
|
{ .name = "Thai, Lao, Tibetan", .start = 0xe00, },
|
|
|
|
|
{ .name = "Myanmar, Georgian, Hangul Jamo", .start = 0x1000, },
|
|
|
|
|
{ .name = "Ethiopic, Ethiopic Supplement, Cherokee", .start = 0x1200, },
|
|
|
|
|
{ .name = "Canadian", .start = 0x1400, },
|
|
|
|
|
{ .name = "Runic, Tagalog, Hanunoo, Buhid, Tagbanwa, Khmer", .start = 0x1600, },
|
|
|
|
|
{ .name = "Mongolian, Canadian Extended, Limbu, Tai Le", .start = 0x1800, },
|
|
|
|
|
{ .name = "Buginese, Tai Tham, Balinese, Sundanese, Batak", .start = 0x1a00, },
|
|
|
|
|
{ .name = "Lepcha, Ol Chiki, Vedic Extensions, Phonetic Extensions", .start = 0x1c00, },
|
|
|
|
|
{ .name = "Latin Extended Additional, Greek Extended", .start = 0x1e00, },
|
|
|
|
|
{ .name = "General Punctuation, Letterlike Symbols, Arrows", .start = 0x2000, },
|
|
|
|
|
{ .name = "Mathematical Operators, Miscellaneous Technical", .start = 0x2200, },
|
|
|
|
|
{ .name = "Control Pictures, Box Drawing, Block Elements", .start = 0x2400, },
|
|
|
|
|
{ .name = "Miscellaneous Symbols, Dingbats", .start = 0x2600, },
|
|
|
|
|
{ .name = "Braille Patterns, Supplemental Arrows", .start = 0x2800, },
|
|
|
|
|
{ .name = "Supplemental Mathematical Operators", .start = 0x2a00, },
|
|
|
|
|
{ .name = "Glagolitic, Georgian Supplement, Tifinagh", .start = 0x2c00, },
|
|
|
|
|
{ .name = "Supplemental Punctuation, CJK Radicals", .start = 0x2e00, },
|
|
|
|
|
};
|
|
|
|
|
size_t sindex;
|
|
|
|
|
ncplane_erase(n);
|
|
|
|
|
for(sindex = 0 ; sindex < sizeof(blocks) / sizeof(*blocks) ; ++sindex){
|
|
|
|
|
uint32_t blockstart = blocks[sindex].start;
|
|
|
|
|
const char* description = blocks[sindex].name;
|
|
|
|
|
int chunk;
|
|
|
|
|
if(ncplane_cursor_move_yx(n, 2, 2)){
|
|
|
|
|
return -1;
|
|
|
|
@ -29,6 +60,12 @@ int unicodeblocks_demo(struct notcurses* nc){
|
|
|
|
|
if(ncplane_printf(n, "Unicode points %04x–%04x\n", blockstart, blockstart + BLOCKSIZE) <= 0){
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if(ncplane_cursor_move_yx(n, 3, 3)){
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if(ncplane_printf(n, description) <= 0){
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
for(chunk = 0 ; chunk < BLOCKSIZE / CHUNKSIZE ; ++chunk){
|
|
|
|
|
if(ncplane_cursor_move_yx(n, 4 + chunk, 2)){
|
|
|
|
|
return -1;
|
|
|
|
|