rendering: lack of term capability is not error #768

If we don't have setaf/setab, then we're not going to set color.
OK, fine. Don't regard it as an error during
notcurses_rasterization(), just don't emit the escape. This is
necessary to run on terminals like vt100, which in turn is
necessary to run unit tests properly on Redhat's koji.
Also, use notcurses_canfade() to avoid just breaking during
fades in intro and trans demos.
This commit is contained in:
nick black 2020-07-05 01:03:04 -04:00
parent 284dfc4fad
commit 5a9e0c6f05
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
4 changed files with 24 additions and 11 deletions

View File

@ -132,6 +132,9 @@ int intro(struct notcurses* nc){
demo_nanosleep(nc, &iter); demo_nanosleep(nc, &iter);
clock_gettime(CLOCK_MONOTONIC_RAW, &now); clock_gettime(CLOCK_MONOTONIC_RAW, &now);
}while(timespec_to_ns(&now) < deadline); }while(timespec_to_ns(&now) < deadline);
if(!notcurses_canfade(nc)){
return 0;
}
struct timespec fade = demodelay; struct timespec fade = demodelay;
return ncplane_fadeout(ncp, &fade, demo_fader, NULL); return ncplane_fadeout(ncp, &fade, demo_fader, NULL);
} }

View File

@ -258,14 +258,16 @@ int trans_demo(struct notcurses* nc){
++x; ++x;
} }
} }
struct ncplane* l = legend(nc, "what say we explore transparency together?"); if(notcurses_canfade(nc)){
DEMO_RENDER(nc); struct ncplane* l = legend(nc, "what say we explore transparency together?");
struct timespec now; DEMO_RENDER(nc);
clock_gettime(CLOCK_MONOTONIC_RAW, &now); struct timespec now;
int err; clock_gettime(CLOCK_MONOTONIC_RAW, &now);
if( (err = ncplane_pulse(l, &demodelay, pulser, &now)) != 2){ int err;
return err; if( (err = ncplane_pulse(l, &demodelay, pulser, &now)) != 2){
return err;
}
ncplane_destroy(l);
} }
ncplane_destroy(l);
return slidepanel(nc); return slidepanel(nc);
} }

View File

@ -538,11 +538,17 @@ term_emit(const char* name __attribute__ ((unused)), const char* seq,
static inline int static inline int
term_bg_palindex(const notcurses* nc, FILE* out, unsigned pal){ term_bg_palindex(const notcurses* nc, FILE* out, unsigned pal){
if(nc->tcache.setab == NULL){
return 0;
}
return term_emit("setab", tiparm(nc->tcache.setab, pal), out, false); return term_emit("setab", tiparm(nc->tcache.setab, pal), out, false);
} }
static inline int static inline int
term_fg_palindex(const notcurses* nc, FILE* out, unsigned pal){ term_fg_palindex(const notcurses* nc, FILE* out, unsigned pal){
if(nc->tcache.setaf == NULL){
return 0;
}
return term_emit("setaf", tiparm(nc->tcache.setaf, pal), out, false); return term_emit("setaf", tiparm(nc->tcache.setaf, pal), out, false);
} }

View File

@ -655,7 +655,7 @@ term_bg_rgb8(bool RGBflag, const char* setab, int colors, FILE* out,
return term_esc_rgb(out, false, r, g, b); return term_esc_rgb(out, false, r, g, b);
}else{ }else{
if(setab == NULL){ if(setab == NULL){
return -1; return 0;
} }
// For 256-color indexed mode, start constructing a palette based off // For 256-color indexed mode, start constructing a palette based off
// the inputs *if we can change the palette*. If more than 256 are used on // the inputs *if we can change the palette*. If more than 256 are used on
@ -682,7 +682,7 @@ term_fg_rgb8(bool RGBflag, const char* setaf, int colors, FILE* out,
return term_esc_rgb(out, true, r, g, b); return term_esc_rgb(out, true, r, g, b);
}else{ }else{
if(setaf == NULL){ if(setaf == NULL){
return -1; return 0;
} }
// For 256-color indexed mode, start constructing a palette based off // For 256-color indexed mode, start constructing a palette based off
// the inputs *if we can change the palette*. If more than 256 are used on // the inputs *if we can change the palette*. If more than 256 are used on
@ -926,7 +926,9 @@ notcurses_rasterize(notcurses* nc, const struct crender* rvec){
if((!noforeground && cell_fg_default_p(srccell)) || (!nobackground && cell_bg_default_p(srccell))){ if((!noforeground && cell_fg_default_p(srccell)) || (!nobackground && cell_bg_default_p(srccell))){
if(!nc->rstate.defaultelidable){ if(!nc->rstate.defaultelidable){
++nc->stats.defaultemissions; ++nc->stats.defaultemissions;
ret |= term_emit("op", nc->tcache.op, out, false); if(nc->tcache.op){
ret |= term_emit("op", nc->tcache.op, out, false);
}
}else{ }else{
++nc->stats.defaultelisions; ++nc->stats.defaultelisions;
} }