mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
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:
parent
284dfc4fad
commit
5a9e0c6f05
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -258,6 +258,7 @@ int trans_demo(struct notcurses* nc){
|
|||||||
++x;
|
++x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(notcurses_canfade(nc)){
|
||||||
struct ncplane* l = legend(nc, "what say we explore transparency together?");
|
struct ncplane* l = legend(nc, "what say we explore transparency together?");
|
||||||
DEMO_RENDER(nc);
|
DEMO_RENDER(nc);
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
@ -267,5 +268,6 @@ int trans_demo(struct notcurses* nc){
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
ncplane_destroy(l);
|
ncplane_destroy(l);
|
||||||
|
}
|
||||||
return slidepanel(nc);
|
return slidepanel(nc);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
if(nc->tcache.op){
|
||||||
ret |= term_emit("op", nc->tcache.op, out, false);
|
ret |= term_emit("op", nc->tcache.op, out, false);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
++nc->stats.defaultelisions;
|
++nc->stats.defaultelisions;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user