mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 09:39:03 -04:00
ncdirect: send sgr0 and sgr to the same FILE, kill DIM/REVERSE #1818
This commit is contained in:
parent
3c75654b67
commit
8cb70a30bb
@ -876,19 +876,19 @@ char* ncdirect_readline(ncdirect* n, const char* prompt){
|
||||
}
|
||||
|
||||
static inline int
|
||||
ncdirect_style_emit(ncdirect* n, unsigned* stylebits, FILE* out){
|
||||
ncdirect_style_emit(ncdirect* n, unsigned stylebits, FILE* out){
|
||||
int r = -1;
|
||||
const char* esc;
|
||||
if(*stylebits == 0 && (esc = get_escape(&n->tcache, ESCAPE_SGR0))){
|
||||
r = term_emit(esc, n->ttyfp, false);
|
||||
if(stylebits == 0 && (esc = get_escape(&n->tcache, ESCAPE_SGR0))){
|
||||
r = term_emit(esc, out, false);
|
||||
}else if( (esc = get_escape(&n->tcache, ESCAPE_SGR)) ){
|
||||
r = term_emit(tiparm(esc,
|
||||
0, // standout
|
||||
*stylebits & NCSTYLE_UNDERLINE,
|
||||
*stylebits & NCSTYLE_REVERSE,
|
||||
stylebits & NCSTYLE_UNDERLINE,
|
||||
0, // reverse
|
||||
0, // blink
|
||||
*stylebits & NCSTYLE_DIM,
|
||||
*stylebits & NCSTYLE_BOLD,
|
||||
0, // dim
|
||||
stylebits & NCSTYLE_BOLD,
|
||||
0, // invisible
|
||||
0, // protect //
|
||||
0), out, false);
|
||||
@ -899,22 +899,22 @@ ncdirect_style_emit(ncdirect* n, unsigned* stylebits, FILE* out){
|
||||
}
|
||||
// sgr will blow away non-sgr properties if they were set beforehand
|
||||
n->stylemask &= ~(NCSTYLE_ITALIC | NCSTYLE_STRUCK | NCSTYLE_UNDERCURL);
|
||||
if(term_setstyle(n->ttyfp, n->stylemask, *stylebits, NCSTYLE_ITALIC,
|
||||
if(term_setstyle(n->ttyfp, n->stylemask, stylebits, NCSTYLE_ITALIC,
|
||||
get_escape(&n->tcache, ESCAPE_SITM),
|
||||
get_escape(&n->tcache, ESCAPE_RITM))){
|
||||
return -1;
|
||||
}
|
||||
if(term_setstyle(n->ttyfp, n->stylemask, *stylebits, NCSTYLE_STRUCK,
|
||||
if(term_setstyle(n->ttyfp, n->stylemask, stylebits, NCSTYLE_STRUCK,
|
||||
get_escape(&n->tcache, ESCAPE_SMXX),
|
||||
get_escape(&n->tcache, ESCAPE_RMXX))){
|
||||
return -1;
|
||||
}
|
||||
if(term_setstyle(n->ttyfp, n->stylemask, *stylebits, NCSTYLE_UNDERCURL,
|
||||
if(term_setstyle(n->ttyfp, n->stylemask, stylebits, NCSTYLE_UNDERCURL,
|
||||
get_escape(&n->tcache, ESCAPE_SMULX),
|
||||
get_escape(&n->tcache, ESCAPE_SMULNOX))){
|
||||
return -1;
|
||||
}
|
||||
n->stylemask = *stylebits;
|
||||
n->stylemask = stylebits;
|
||||
// sgr resets colors, so set them back up if not defaults
|
||||
if(r == 0){
|
||||
// emitting an sgr resets colors. if we want to be default, that's no
|
||||
@ -953,7 +953,7 @@ int ncdirect_styles_on(ncdirect* n, unsigned stylebits){
|
||||
|
||||
int ncdirect_on_styles(ncdirect* n, unsigned stylebits){
|
||||
uint32_t stylemask = n->stylemask | stylebits;
|
||||
if(ncdirect_style_emit(n, &stylemask, n->ttyfp) == 0){
|
||||
if(ncdirect_style_emit(n, stylemask, n->ttyfp) == 0){
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
@ -970,7 +970,7 @@ unsigned ncdirect_styles(ncdirect* n){
|
||||
// turn off any specified stylebits
|
||||
int ncdirect_off_styles(ncdirect* n, unsigned stylebits){
|
||||
uint32_t stylemask = n->stylemask & ~stylebits;
|
||||
if(ncdirect_style_emit(n, &stylemask, n->ttyfp) == 0){
|
||||
if(ncdirect_style_emit(n, stylemask, n->ttyfp) == 0){
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
@ -986,7 +986,7 @@ int ncdirect_set_styles(ncdirect* n, unsigned stylebits){
|
||||
return -1;
|
||||
}
|
||||
uint32_t stylemask = stylebits;
|
||||
if(ncdirect_style_emit(n, &stylemask, n->ttyfp)){
|
||||
if(ncdirect_style_emit(n, stylemask, n->ttyfp)){
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user