[keller] if we expect success, but fail, error out #2278

pull/2292/head
nick black 3 years ago
parent 3dafea8e91
commit a4896720e7
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -1,17 +1,22 @@
#include "demo.h" #include "demo.h"
static bool truefxn(const struct notcurses* nc){ (void)nc; return true; }
// show it with each blitter, with a legend // show it with each blitter, with a legend
static int static int
visualize(struct notcurses* nc, struct ncvisual* ncv){ visualize(struct notcurses* nc, struct ncvisual* ncv){
struct timespec kdelay; struct timespec kdelay;
timespec_div(&demodelay, 2, &kdelay); timespec_div(&demodelay, 2, &kdelay);
ncblitter_e bs[] = { const struct {
NCBLIT_BRAILLE, ncblitter_e b;
NCBLIT_1x1, bool (*f)(const struct notcurses*);
NCBLIT_2x1, } bs[] = {
NCBLIT_2x2, { NCBLIT_BRAILLE, notcurses_canbraille, },
NCBLIT_3x2, { NCBLIT_1x1, truefxn, }, // everyone can do spaces
NCBLIT_PIXEL, { NCBLIT_2x1, notcurses_canhalfblock, },
{ NCBLIT_2x2, notcurses_canquadrant, },
{ NCBLIT_3x2, notcurses_cansextant, },
{ NCBLIT_PIXEL, notcurses_canpixel, },
}; };
struct ncplane* stdn = notcurses_stdplane(nc); struct ncplane* stdn = notcurses_stdplane(nc);
ncplane_set_fg_rgb(stdn, 0xffffff); ncplane_set_fg_rgb(stdn, 0xffffff);
@ -25,7 +30,7 @@ visualize(struct notcurses* nc, struct ncvisual* ncv){
struct ncvisual_options vopts = { struct ncvisual_options vopts = {
.n = notcurses_stdplane(nc), .n = notcurses_stdplane(nc),
.scaling = NCSCALE_SCALE, .scaling = NCSCALE_SCALE,
.blitter = bs[i], .blitter = bs[i].b,
.flags = NCVISUAL_OPTION_NODEGRADE .flags = NCVISUAL_OPTION_NODEGRADE
| NCVISUAL_OPTION_HORALIGNED | NCVISUAL_OPTION_HORALIGNED
| NCVISUAL_OPTION_VERALIGNED | NCVISUAL_OPTION_VERALIGNED
@ -47,11 +52,14 @@ visualize(struct notcurses* nc, struct ncvisual* ncv){
} }
//fprintf(stderr, "X: %d truex: %d scalex: %d\n", vopts.x, truex, scalex); //fprintf(stderr, "X: %d truex: %d scalex: %d\n", vopts.x, truex, scalex);
if(!n){ if(!n){
if(bs[i].f(nc)){
return -1;
}
ncplane_on_styles(stdn, NCSTYLE_ITALIC); ncplane_on_styles(stdn, NCSTYLE_ITALIC);
ncplane_printf_aligned(stdn, ncplane_dim_y(stdn) / 2 - 1, NCALIGN_CENTER, "not available"); ncplane_printf_aligned(stdn, ncplane_dim_y(stdn) / 2 - 1, NCALIGN_CENTER, "not available");
ncplane_off_styles(stdn, NCSTYLE_ITALIC); ncplane_off_styles(stdn, NCSTYLE_ITALIC);
} }
const char* name = notcurses_str_blitter(bs[i]); const char* name = notcurses_str_blitter(bs[i].b);
ncplane_printf_aligned(stdn, ncplane_dim_y(stdn) / 2 - 3, NCALIGN_CENTER, "%sblitter", name); ncplane_printf_aligned(stdn, ncplane_dim_y(stdn) / 2 - 3, NCALIGN_CENTER, "%sblitter", name);
int ret = demo_render(nc); int ret = demo_render(nc);
if(ret){ if(ret){

Loading…
Cancel
Save