check for support in ncdirect_on_styles()

This commit is contained in:
nick black 2021-07-24 21:31:15 -04:00
parent 540442fe9f
commit 93fe6db376
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -959,12 +959,15 @@ int ncdirect_styles_on(ncdirect* n, unsigned stylebits){
} }
int ncdirect_on_styles(ncdirect* n, unsigned stylebits){ int ncdirect_on_styles(ncdirect* n, unsigned stylebits){
uint32_t stylemask = n->stylemask | stylebits; if((stylebits & n->tcache.supported_styles) < stylebits){ // unsupported styles
if(ncdirect_style_emit(n, stylemask, n->ttyfp) == 0){
return 0;
}
return -1; return -1;
} }
uint32_t stylemask = n->stylemask | stylebits;
if(ncdirect_style_emit(n, stylemask, n->ttyfp)){
return -1;
}
return 0;
}
int ncdirect_styles_off(ncdirect* n, unsigned stylebits){ int ncdirect_styles_off(ncdirect* n, unsigned stylebits){
return ncdirect_off_styles(n, stylebits); return ncdirect_off_styles(n, stylebits);
@ -977,11 +980,11 @@ unsigned ncdirect_styles(ncdirect* n){
// turn off any specified stylebits // turn off any specified stylebits
int ncdirect_off_styles(ncdirect* n, unsigned stylebits){ int ncdirect_off_styles(ncdirect* n, unsigned stylebits){
uint32_t stylemask = n->stylemask & ~stylebits; uint32_t stylemask = n->stylemask & ~stylebits;
if(ncdirect_style_emit(n, stylemask, n->ttyfp) == 0){ if(ncdirect_style_emit(n, stylemask, n->ttyfp)){
return 0;
}
return -1; return -1;
} }
return 0;
}
int ncdirect_styles_set(ncdirect* n, unsigned stylebits){ int ncdirect_styles_set(ncdirect* n, unsigned stylebits){
return ncdirect_set_styles(n, stylebits); return ncdirect_set_styles(n, stylebits);