move italics into esctable #1525

This commit is contained in:
nick black 2021-05-26 07:33:54 -04:00 committed by Nick Black
parent b67315a17e
commit 92873d6b6e
4 changed files with 14 additions and 10 deletions

View File

@ -847,7 +847,8 @@ int ncdirect_on_styles(ncdirect* n, unsigned stylebits){
uint32_t stylemask = n->stylemask | stylebits;
if(ncdirect_style_emit(n, stylemask, n->ttyfp) == 0){
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC,
n->tcache.italics, n->tcache.italoff)){
get_escape(&n->tcache, ESCAPE_SITM),
get_escape(&n->tcache, ESCAPE_RITM))){
return 0;
}
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_STRUCK,
@ -869,7 +870,8 @@ int ncdirect_off_styles(ncdirect* n, unsigned stylebits){
uint32_t stylemask = n->stylemask & ~stylebits;
if(ncdirect_style_emit(n, stylemask, n->ttyfp) == 0){
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC,
n->tcache.italics, n->tcache.italoff)){
get_escape(&n->tcache, ESCAPE_SITM),
get_escape(&n->tcache, ESCAPE_RITM))){
return -1;
}
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_STRUCK,
@ -892,7 +894,8 @@ int ncdirect_set_styles(ncdirect* n, unsigned stylebits){
if(ncdirect_style_emit(n, stylemask, n->ttyfp) == 0){
n->stylemask &= !(NCSTYLE_ITALIC | NCSTYLE_STRUCK); // sgr clears both
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC,
n->tcache.italics, n->tcache.italoff)){
get_escape(&n->tcache, ESCAPE_SITM),
get_escape(&n->tcache, ESCAPE_RITM))){
return -1;
}
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_STRUCK,

View File

@ -638,7 +638,8 @@ term_setstyles(FILE* out, notcurses* nc, const nccell* c){
nc->rstate.curattr &= ~(NCSTYLE_ITALIC | NCSTYLE_STRUCK);
}
ret |= term_setstyle(out, nc->rstate.curattr, cellattr, NCSTYLE_ITALIC,
nc->tcache.italics, nc->tcache.italoff);
get_escape(&nc->tcache, ESCAPE_SITM),
get_escape(&nc->tcache, ESCAPE_RITM));
ret |= term_setstyle(out, nc->rstate.curattr, cellattr, NCSTYLE_STRUCK,
nc->tcache.struck, nc->tcache.struckoff);
nc->rstate.curattr = cellattr;

View File

@ -37,6 +37,8 @@ typedef enum {
ESCAPE_CIVIS, // "civis" make the cursor invisiable
ESCAPE_CNORM, // "cnorm" restore the cursor to normal
ESCAPE_OC, // "oc" restore original colors
ESCAPE_SITM, // "sitm" start italics
ESCAPE_RITM, // "ritm" end italics
ESCAPE_MAX
} escape_e;
@ -55,8 +57,6 @@ typedef struct tinfo {
char* cud; // move N cells down
char* cuf1; // move 1 cell right
char* home; // home cursor
char* italics; // NCSTYLE_ITALIC
char* italoff; // NCSTYLE_ITALIC (disable)
char* struck; // NCSTYLE_STRUCK
char* struckoff;// NCSTYLE_STRUCK (disable)
char* initc; // set a palette entry's RGB value

View File

@ -206,6 +206,8 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname,
{ ESCAPE_CIVIS, "civis", },
{ ESCAPE_SGR, "sgr", },
{ ESCAPE_SGR0, "sgr0", },
{ ESCAPE_SITM, "sitm", },
{ ESCAPE_RITM, "ritm", },
{ ESCAPE_MAX, NULL, },
};
size_t tablelen = 0;
@ -244,10 +246,6 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname,
}
}
}
// italics are never handled by sgr, so we keep these escapes, but
// italics *can* be locked out by ncv
terminfostr(&ti->italics, "sitm"); // begin italic mode
terminfostr(&ti->italoff, "ritm"); // end italic mode
terminfostr(&ti->home, "home"); // home the cursor
terminfostr(&ti->clearscr, "clear");// clear screen, home cursor
terminfostr(&ti->cuu, "cuu"); // move N up
@ -262,6 +260,8 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname,
// we think sgr supports bold, which...might be valid? i'm unsure. futher,
// some terminals cannot combine certain styles with colors. don't
// advertise support for the style in that case.
// italics are never handled by sgr, so we keep those escapes, but
// italics *can* be locked out by ncv
const struct style {
unsigned s; // NCSTYLE_* value
const char* tinfo; // terminfo capability for conditional permit