notcurses-input: colorize output

This commit is contained in:
nick black 2019-12-08 14:35:29 -05:00
parent 3085a5db31
commit 949e531038
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -67,6 +67,7 @@ int main(void){
notcurses_stop(nc); notcurses_stop(nc);
return EXIT_FAILURE; return EXIT_FAILURE;
} }
ncplane_bg_default(n);
int y = 1; int y = 1;
std::deque<cell> cells; std::deque<cell> cells;
ncspecial_key special; ncspecial_key special;
@ -80,15 +81,28 @@ int main(void){
if(cell_simple_p(&c)){ if(cell_simple_p(&c)){
char kp = c.gcluster; char kp = c.gcluster;
if(kp == 0){ if(kp == 0){
if(special == 0){
ncplane_set_fg_rgb(n, 255, 95, 255);
if(ncplane_printf(n, "Read garbage: [0x%02x (%02d)] '%s'\n",
special, special, nckeystr(special)) < 0){
break;
}
}else{
ncplane_set_fg_rgb(n, 175, 175, 255);
if(ncplane_printf(n, "Got special key: [0x%02x (%02d)] '%s'\n", if(ncplane_printf(n, "Got special key: [0x%02x (%02d)] '%s'\n",
special, special, nckeystr(special)) < 0){ special, special, nckeystr(special)) < 0){
break; break;
} }
}else if(ncplane_printf(n, "Got ASCII: [0x%02x (%03d)] '%lc'\n", }
}else{
ncplane_set_fg_rgb(n, 175, 255, 135);
if(ncplane_printf(n, "Got ASCII: [0x%02x (%03d)] '%lc'\n",
kp, kp, isprint(kp) ? kp : printutf8(kp)) < 0){ kp, kp, isprint(kp) ? kp : printutf8(kp)) < 0){
break; break;
} }
}
}else{ }else{
ncplane_set_fg_rgb(n, 215, 0, 95);
ncplane_printf(n, "Curious! %d%5s\n", c.gcluster, ""); // FIXME ncplane_printf(n, "Curious! %d%5s\n", c.gcluster, ""); // FIXME
} }
// FIXME reprint all lines, fading older ones // FIXME reprint all lines, fading older ones