mojibake: first row of unicode 13 table

pull/747/head
nick black 4 years ago committed by Nick Black
parent 32180235bd
commit bca52922dd

@ -1,20 +1,39 @@
#include "demo.h" #include "demo.h"
static struct ncplane* static struct ncplane*
unicode52(struct ncplane* std, int y){ mojiplane(struct ncplane* title, int y, int rows, const char* summary){
const int ROWS = 25; struct ncplane* n = ncplane_aligned(title, rows, 64, y, NCALIGN_CENTER, NULL);
struct ncplane* n = ncplane_aligned(std, ROWS, 64, y, NCALIGN_CENTER, NULL);
if(ncplane_perimeter_rounded(n, 0, 0, 0) < 0){ if(ncplane_perimeter_rounded(n, 0, 0, 0) < 0){
ncplane_destroy(n); ncplane_destroy(n);
return NULL; return NULL;
} }
uint64_t channels = 0; uint64_t channels = 0;
channels_set_bg(&channels, 0x0); channels_set_bg(&channels, 0x0);
if(ncplane_set_base(n, " ", 0, channels) < 0 || ncplane_set_fg(n, 0x40d040) if(ncplane_set_fg(n, 0x40d0d0) || ncplane_set_bg(n, 0)){
|| ncplane_set_bg(n, 0)){ ncplane_destroy(n);
return NULL;
}
const int x = ncplane_align(n, NCALIGN_RIGHT, strlen(summary) + 2);
if(ncplane_putstr_yx(n, rows - 1, x, summary) < 0){
ncplane_destroy(n);
return NULL;
}
if(ncplane_set_base(n, " ", 0, channels) < 0 || ncplane_set_fg(n, 0x40d040)){
ncplane_destroy(n); ncplane_destroy(n);
return NULL; return NULL;
} }
ncplane_move_below(n, title);
return n;
}
static struct ncplane*
unicode52(struct ncplane* title, int y){
const char SUMMARY[] = "[Unicode 6.0 (2010), 608 codepoints]";
const int ROWS = 25;
struct ncplane* n = mojiplane(title, y, ROWS, SUMMARY);
if(n == NULL){
return NULL;
}
ncplane_putstr_yx(n, 1, 1, "😃😄😁😆😅😂😉😊😇😍😘😚😋😜😝😐😶😏😒😌😔😪😷😵😎😲😳😨😰😥😢😭"); ncplane_putstr_yx(n, 1, 1, "😃😄😁😆😅😂😉😊😇😍😘😚😋😜😝😐😶😏😒😌😔😪😷😵😎😲😳😨😰😥😢😭");
ncplane_putstr_yx(n, 2, 1, "😱😖😣😞😓😩😫😤😡😠😈👿💀💩👹👺👻👽👾😺😸😹😻😼😽🙀😿😾🙈🙉🙊💋"); ncplane_putstr_yx(n, 2, 1, "😱😖😣😞😓😩😫😤😡😠😈👿💀💩👹👺👻👽👾😺😸😹😻😼😽🙀😿😾🙈🙉🙊💋");
ncplane_putstr_yx(n, 3, 1, "💌💘💝💖💗💓💞💕💟💔💛💚💙💜💯💢💥💫💦💨💣💬💭💤👋✋👌👈👉👆👇👍"); ncplane_putstr_yx(n, 3, 1, "💌💘💝💖💗💓💞💕💟💔💛💚💙💜💯💢💥💫💦💨💣💬💭💤👋✋👌👈👉👆👇👍");
@ -38,10 +57,28 @@ unicode52(struct ncplane* std, int y){
ncplane_putstr_yx(n, 21, 1, "\ufe0f\ufe0f⏫🔽⏬🎦🔅🔆📶📳📴➕➖➗❓❔❕💱💲🔱📛🔰✅❌❎➰➿🔟🔠🔡🔢"); ncplane_putstr_yx(n, 21, 1, "\ufe0f\ufe0f⏫🔽⏬🎦🔅🔆📶📳📴➕➖➗❓❔❕💱💲🔱📛🔰✅❌❎➰➿🔟🔠🔡🔢");
ncplane_putstr_yx(n, 22, 1, "\ufe0f🔣🔤🅰🆎🅱🆑🆒🆓🆔🆕🆖🅾🆗🆘🆙🆚🈁🈂🈷🈶🉐🈹🈲🉑🈸🈴🈳🈺🈵🔴🔵🔶🔷"); ncplane_putstr_yx(n, 22, 1, "\ufe0f🔣🔤🅰🆎🅱🆑🆒🆓🆔🆕🆖🅾🆗🆘🆙🆚🈁🈂🈷🈶🉐🈹🈲🉑🈸🈴🈳🈺🈵🔴🔵🔶🔷");
ncplane_putstr_yx(n, 23, 1, "🔸🔹🔺🔻💠🔘🔳🔲🏁🚩🎌⛧⛤⛢⛦⛥"); ncplane_putstr_yx(n, 23, 1, "🔸🔹🔺🔻💠🔘🔳🔲🏁🚩🎌⛧⛤⛢⛦⛥");
const char SUMMARY[] = "[Unicode 6.0 (2010), 608 codepoints]"; return n;
ncplane_set_fg(n, 0x40d0d0); }
const int x = ncplane_align(n, NCALIGN_RIGHT, strlen(SUMMARY) + 2);
ncplane_putstr_yx(n, ROWS - 1, x, SUMMARY); static struct ncplane*
unicode13(struct ncplane* title, int y){
const char SUMMARY[] = "[Unicode 13.0 (2010), 56 codepoints]";
const int ROWS = 4;
struct ncplane* n = mojiplane(title, y, ROWS, SUMMARY);
if(n == NULL){
return NULL;
}
ncplane_putstr_yx(n, 1, 1, "\xf0\x9f\xa5\xb2\xf0\x9f\xa5\xb8\xf0\x9f\xa4\x8c"
"\xf0\x9f\xab\x80\xf0\x9f\xab\x81\xf0\x9f\xa5\xb7"
"\xf0\x9f\xab\x82\xf0\x9f\xa6\xac\xf0\x9f\xa6\xa3"
"\xf0\x9f\xa6\xab\xf0\x9f\xa6\xa4\xf0\x9f\xaa\xb6"
"\xf0\x9f\xa6\xad\xf0\x9f\xaa\xb2\xf0\x9f\xaa\xb3"
"\xf0\x9f\xaa\xb0\xf0\x9f\xaa\xb1\xf0\x9f\xaa\xb4"
"\xf0\x9f\xab\x90\xf0\x9f\xab\x92\xf0\x9f\xab\x91"
"\xf0\x9f\xab\x93\xf0\x9f\xab\x94\xf0\x9f\xab\x95"
"\xf0\x9f\xab\x96\xf0\x9f\xa7\x8b\xf0\x9f\xaa\xa8"
"\xf0\x9f\xaa\xb5\xf0\x9f\x9b\x96\xf0\x9f\x9b\xbb"
"\xf0\x9f\x9b\xbc\xf0\x9f\xaa\x84");
return n; return n;
} }
@ -84,7 +121,8 @@ int mojibake_demo(struct notcurses* nc){
return -1; return -1;
} }
struct ncplane* planes[] = { struct ncplane* planes[] = {
unicode52(std, dimy - 1), unicode52(title, dimy - 1),
unicode13(title, dimy + 1),
}; };
// scroll the various planes up from the bottom. none are onscreen save the // scroll the various planes up from the bottom. none are onscreen save the
// first, which starts at the bottom. each time one clears, we bring the // first, which starts at the bottom. each time one clears, we bring the
@ -94,12 +132,14 @@ int mojibake_demo(struct notcurses* nc){
struct timespec stepdelay; struct timespec stepdelay;
// two seconds onscreen per plane at standard (1s) delay // two seconds onscreen per plane at standard (1s) delay
timespec_div(&demodelay, dimy / 2, &stepdelay); timespec_div(&demodelay, dimy / 2, &stepdelay);
ncplane_move_below(planes[0], title);
do{ do{
unsigned u = topmost; unsigned u = topmost;
do{ do{
int y, x, leny; int y, x, leny;
ncplane_yx(planes[u], &y, &x); ncplane_yx(planes[u], &y, &x);
if(y >= dimy){
break;
}
if(ncplane_move_yx(planes[u], y - 1, x)){ if(ncplane_move_yx(planes[u], y - 1, x)){
goto err; goto err;
} }
@ -108,7 +148,11 @@ int mojibake_demo(struct notcurses* nc){
++topmost; ++topmost;
} }
if(leny + y + 1 == dimy - 1){ if(leny + y + 1 == dimy - 1){
// FIXME bring next one on if(u + 1 < sizeof(planes) / sizeof(*planes)){
if(ncplane_move_yx(planes[u + 1], dimy - 1, x)){
goto err;
}
}
} }
++u; ++u;
}while(u < sizeof(planes) / sizeof(*planes)); }while(u < sizeof(planes) / sizeof(*planes));

Loading…
Cancel
Save