uniblock: drop rtl blocks for now #183 #259

This commit is contained in:
nick black 2020-01-12 10:15:56 -05:00
parent 49d684c772
commit 1b83c8b182
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 73 additions and 67 deletions

View File

@ -14,7 +14,9 @@ notcurses-demo - Show off some notcurses features
**notcurses-demo** demonstrates the capabilities of the notcurses library. It **notcurses-demo** demonstrates the capabilities of the notcurses library. It
can be run in any terminal emulator or console with a correct terminfo(5) can be run in any terminal emulator or console with a correct terminfo(5)
database, but is at is best in a "DirectColor" 24bpp RGB environment. database, but is at is best in a "DirectColor" 24bpp RGB environment. If
**notcurses-demo** seems to generate garbage, something is likely configured in
a way that is going to prevent notcurses from working.
The demonstrations include: The demonstrations include:

View File

@ -20,7 +20,10 @@ fade_block(struct notcurses* nc, struct ncplane* nn, const struct timespec* subd
} }
static int static int
draw_block(struct ncplane* nn, uint32_t blockstart){ draw_block(struct ncplane* nn, uint32_t blockstart, bool rtl){
if(rtl){
return 0;
}
int dimx, dimy; int dimx, dimy;
ncplane_dim_yx(nn, &dimy, &dimx); ncplane_dim_yx(nn, &dimy, &dimx);
cell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER; cell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER;
@ -50,7 +53,7 @@ draw_block(struct ncplane* nn, uint32_t blockstart){
int z; int z;
for(z = 0 ; z < CHUNKSIZE ; ++z){ for(z = 0 ; z < CHUNKSIZE ; ++z){
wchar_t w[2] = { blockstart + chunk * CHUNKSIZE + z, L'\0' }; wchar_t w[2] = { blockstart + chunk * CHUNKSIZE + z, L'\0' };
char utf8arr[MB_CUR_MAX * 2 + 1]; char utf8arr[MB_CUR_MAX * 3 + 1];
if(wcswidth(w, sizeof(w) / sizeof(*w)) >= 1 && iswgraph(w[0])){ if(wcswidth(w, sizeof(w) / sizeof(*w)) >= 1 && iswgraph(w[0])){
mbstate_t ps; mbstate_t ps;
memset(&ps, 0, sizeof(ps)); memset(&ps, 0, sizeof(ps));
@ -87,72 +90,73 @@ int unicodeblocks_demo(struct notcurses* nc){
// marginally covered by mainstream fonts, some not at all. we explicitly // marginally covered by mainstream fonts, some not at all. we explicitly
// list the ones we want. // list the ones we want.
const struct { const struct {
bool rtl; // are there right-to-left chars?
const char* name; const char* name;
uint32_t start; uint32_t start;
} blocks[] = { } blocks[] = {
{ .name = "Basic Latin, Latin 1 Supplement, Latin Extended", .start = 0, }, { .rtl = false, .name = "Basic Latin, Latin 1 Supplement, Latin Extended", .start = 0, },
{ .name = "IPA Extensions, Spacing Modifiers, Greek and Coptic", .start = 0x200, }, { .rtl = false, .name = "IPA Extensions, Spacing Modifiers, Greek and Coptic", .start = 0x200, },
{ .name = "Cyrillic, Cyrillic Supplement, Armenian, Hebrew", .start = 0x400, }, { .rtl = true, .name = "Cyrillic, Cyrillic Supplement, Armenian, Hebrew", .start = 0x400, },
{ .name = "Arabic, Syriac, Arabic Supplement", .start = 0x600, }, { .rtl = true, .name = "Arabic, Syriac, Arabic Supplement", .start = 0x600, },
{ .name = "Samaritan, Mandaic, Devanagari, Bengali", .start = 0x800, }, { .rtl = true, .name = "Samaritan, Mandaic, Devanagari, Bengali", .start = 0x800, },
{ .name = "Gurmukhi, Gujarati, Oriya, Tamil", .start = 0xa00, }, { .rtl = false, .name = "Gurmukhi, Gujarati, Oriya, Tamil", .start = 0xa00, },
{ .name = "Telugu, Kannada, Malayalam, Sinhala", .start = 0xc00, }, { .rtl = false, .name = "Telugu, Kannada, Malayalam, Sinhala", .start = 0xc00, },
{ .name = "Thai, Lao, Tibetan", .start = 0xe00, }, { .rtl = false, .name = "Thai, Lao, Tibetan", .start = 0xe00, },
{ .name = "Myanmar, Georgian, Hangul Jamo", .start = 0x1000, }, { .rtl = false, .name = "Myanmar, Georgian, Hangul Jamo", .start = 0x1000, },
{ .name = "Ethiopic, Ethiopic Supplement, Cherokee", .start = 0x1200, }, { .rtl = false, .name = "Ethiopic, Ethiopic Supplement, Cherokee", .start = 0x1200, },
{ .name = "Canadian", .start = 0x1400, }, { .rtl = false, .name = "Canadian", .start = 0x1400, },
{ .name = "Runic, Tagalog, Hanunoo, Buhid, Tagbanwa, Khmer", .start = 0x1600, }, { .rtl = false, .name = "Runic, Tagalog, Hanunoo, Buhid, Tagbanwa, Khmer", .start = 0x1600, },
{ .name = "Mongolian, Canadian Extended, Limbu, Tai Le", .start = 0x1800, }, { .rtl = false, .name = "Mongolian, Canadian Extended, Limbu, Tai Le", .start = 0x1800, },
{ .name = "Buginese, Tai Tham, Balinese, Sundanese, Batak", .start = 0x1a00, }, { .rtl = false, .name = "Buginese, Tai Tham, Balinese, Sundanese, Batak", .start = 0x1a00, },
{ .name = "Lepcha, Ol Chiki, Vedic Extensions, Phonetic Extensions", .start = 0x1c00, }, { .rtl = false, .name = "Lepcha, Ol Chiki, Vedic Extensions, Phonetic Extensions", .start = 0x1c00, },
{ .name = "Latin Extended Additional, Greek Extended", .start = 0x1e00, }, { .rtl = false, .name = "Latin Extended Additional, Greek Extended", .start = 0x1e00, },
{ .name = "General Punctuation, Letterlike Symbols, Arrows", .start = 0x2000, }, { .rtl = false, .name = "General Punctuation, Letterlike Symbols, Arrows", .start = 0x2000, },
{ .name = "Mathematical Operators, Miscellaneous Technical", .start = 0x2200, }, { .rtl = false, .name = "Mathematical Operators, Miscellaneous Technical", .start = 0x2200, },
{ .name = "Control Pictures, Box Drawing, Block Elements", .start = 0x2400, }, { .rtl = false, .name = "Control Pictures, Box Drawing, Block Elements", .start = 0x2400, },
{ .name = "Miscellaneous Symbols, Dingbats", .start = 0x2600, }, { .rtl = false, .name = "Miscellaneous Symbols, Dingbats", .start = 0x2600, },
{ .name = "Braille Patterns, Supplemental Arrows", .start = 0x2800, }, { .rtl = false, .name = "Braille Patterns, Supplemental Arrows", .start = 0x2800, },
{ .name = "Supplemental Mathematical Operators", .start = 0x2a00, }, { .rtl = false, .name = "Supplemental Mathematical Operators", .start = 0x2a00, },
{ .name = "Glagolitic, Georgian Supplement, Tifinagh", .start = 0x2c00, }, { .rtl = false, .name = "Glagolitic, Georgian Supplement, Tifinagh", .start = 0x2c00, },
{ .name = "Supplemental Punctuation, CJK Radicals", .start = 0x2e00, }, { .rtl = false, .name = "Supplemental Punctuation, CJK Radicals", .start = 0x2e00, },
{ .name = "CJK Symbols and Punctuation", .start = 0x3000, }, { .rtl = false, .name = "CJK Symbols and Punctuation", .start = 0x3000, },
{ .name = "Enclosed CJK Letters and Months", .start = 0x3200, }, { .rtl = false, .name = "Enclosed CJK Letters and Months", .start = 0x3200, },
{ .name = "CJK Unified Ideographs Extension A", .start = 0x3400, }, { .rtl = false, .name = "CJK Unified Ideographs Extension A", .start = 0x3400, },
{ .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x3600, }, { .rtl = false, .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x3600, },
{ .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x3800, }, { .rtl = false, .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x3800, },
{ .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x3a00, }, { .rtl = false, .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x3a00, },
{ .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x3c00, }, { .rtl = false, .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x3c00, },
{ .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x3e00, }, { .rtl = false, .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x3e00, },
{ .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x4000, }, { .rtl = false, .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x4000, },
{ .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x4200, }, { .rtl = false, .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x4200, },
{ .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x4400, }, { .rtl = false, .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x4400, },
{ .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x4600, }, { .rtl = false, .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x4600, },
{ .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x4800, }, { .rtl = false, .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x4800, },
{ .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x4a00, }, { .rtl = false, .name = "CJK Unified Ideographs Extension A (cont.)", .start = 0x4a00, },
{ .name = "CJK Unified Ideographs Extension A, Yijang Hexagram", .start = 0x4c00, }, { .rtl = false, .name = "CJK Unified Ideographs Extension A, Yijang Hexagram", .start = 0x4c00, },
{ .name = "CJK Unified Ideographs", .start = 0x4e00, }, { .rtl = false, .name = "CJK Unified Ideographs", .start = 0x4e00, },
{ .name = "Yi Syllables", .start = 0xa000, }, { .rtl = false, .name = "Yi Syllables", .start = 0xa000, },
{ .name = "Yi Syllables", .start = 0xa200, }, { .rtl = false, .name = "Yi Syllables", .start = 0xa200, },
{ .name = "Yi Syllables, Yi Radicals, Lisu, Vai", .start = 0xa400, }, { .rtl = false, .name = "Yi Syllables, Yi Radicals, Lisu, Vai", .start = 0xa400, },
{ .name = "Vai, Cyrillic Extended-B, Bamum, Tone Letters, Latin Extended-D", .start = 0xa600, }, { .rtl = false, .name = "Vai, Cyrillic Extended-B, Bamum, Tone Letters, Latin Extended-D", .start = 0xa600, },
{ .name = "Halfwidth and Fullwidth Forms", .start = 0xff00, }, { .rtl = false, .name = "Halfwidth and Fullwidth Forms", .start = 0xff00, },
{ .name = "Linear B Syllabary, Linear B Ideograms, Aegean Numbers, Phaistos Disc", .start = 0x10000, }, { .rtl = false, .name = "Linear B Syllabary, Linear B Ideograms, Aegean Numbers, Phaistos Disc", .start = 0x10000, },
{ .name = "Lycian, Carian, Coptic Epact Numbers, Old Italic, Gothic, Old Permic", .start = 0x10200, }, { .rtl = false, .name = "Lycian, Carian, Coptic Epact Numbers, Old Italic, Gothic, Old Permic", .start = 0x10200, },
{ .name = "Cuneiform", .start = 0x12000, }, { .rtl = false, .name = "Cuneiform", .start = 0x12000, },
{ .name = "Cuneiform (cont.)", .start = 0x12200, }, { .rtl = false, .name = "Cuneiform (cont.)", .start = 0x12200, },
{ .name = "Byzantine Musical Symbols, Musical Symbols", .start = 0x1d000, }, { .rtl = false, .name = "Byzantine Musical Symbols, Musical Symbols", .start = 0x1d000, },
{ .name = "Ancient Greek Musical Notation, Mayan Numerals, Tai Xuan Jing, Counting Rods", .start = 0x1d200, }, { .rtl = false, .name = "Ancient Greek Musical Notation, Mayan Numerals, Tai Xuan Jing, Counting Rods", .start = 0x1d200, },
{ .name = "Mathematical Alphanumeric Symbols", .start = 0x1d400, }, { .rtl = false, .name = "Mathematical Alphanumeric Symbols", .start = 0x1d400, },
{ .name = "Mathematical Alphanumeric Symbols (cont.)", .start = 0x1d600, }, { .rtl = false, .name = "Mathematical Alphanumeric Symbols (cont.)", .start = 0x1d600, },
{ .name = "Sutton SignWriting", .start = 0x1d800, }, { .rtl = false, .name = "Sutton SignWriting", .start = 0x1d800, },
{ .name = "Glagolitic Supplement, Nyiakeng Puachue Hmong", .start = 0x1e000, }, { .rtl = false, .name = "Glagolitic Supplement, Nyiakeng Puachue Hmong", .start = 0x1e000, },
{ .name = "Ottoman Siyaq Numbers", .start = 0x1ed00, }, { .rtl = false, .name = "Ottoman Siyaq Numbers", .start = 0x1ed00, },
{ .name = "Arabic Mathematical Alphabetic Symbols", .start = 0x1ee00, }, { .rtl = false, .name = "Arabic Mathematical Alphabetic Symbols", .start = 0x1ee00, },
{ .name = "Mahjong Tiles, Domino Tiles, Playing Cards", .start = 0x1f000, }, { .rtl = false, .name = "Mahjong Tiles, Domino Tiles, Playing Cards", .start = 0x1f000, },
{ .name = "Enclosed Ideographic Supplement, Miscellaneous Symbols", .start = 0x1f200, }, { .rtl = false, .name = "Enclosed Ideographic Supplement, Miscellaneous Symbols", .start = 0x1f200, },
{ .name = "Miscellaneous Symbols and Pictographs (cont.)", .start = 0x1f400, }, { .rtl = false, .name = "Miscellaneous Symbols and Pictographs (cont.)", .start = 0x1f400, },
{ .name = "Emoticons, Ornamental Dingbats, Transport and Map Symbols", .start = 0x1f600, }, { .rtl = false, .name = "Emoticons, Ornamental Dingbats, Transport and Map Symbols", .start = 0x1f600, },
{ .name = "Supplemental Arrows-C, Supplemental Symbols", .start = 0x1f800, }, { .rtl = false, .name = "Supplemental Arrows-C, Supplemental Symbols", .start = 0x1f800, },
{ .name = "Chess Symbols, Symbols and Pictographs Extended-A", .start = 0x1fa00, }, { .rtl = false, .name = "Chess Symbols, Symbols and Pictographs Extended-A", .start = 0x1fa00, },
}; };
size_t sindex; size_t sindex;
// we don't want a full delay period for each one, urk...or do we? // we don't want a full delay period for each one, urk...or do we?
@ -175,7 +179,7 @@ int unicodeblocks_demo(struct notcurses* nc){
if(hud){ if(hud){
ncplane_move_below_unsafe(nn, hud); ncplane_move_below_unsafe(nn, hud);
} }
if(draw_block(nn, blockstart)){ if(draw_block(nn, blockstart, blocks[sindex].rtl)){
return -1; return -1;
} }
ncplane_set_fg_rgb(n, 0x40, 0xc0, 0x40); ncplane_set_fg_rgb(n, 0x40, 0xc0, 0x40);