move blink/dim/reverse/uline/standout to bools #1525

pull/1693/head
nick black 3 years ago committed by Nick Black
parent c4e2932c76
commit 3b4057d550

@ -55,11 +55,6 @@ typedef struct tinfo {
char* cud; // move N cells down
char* cuf1; // move 1 cell right
char* home; // home cursor
char* standout; // NCSTYLE_STANDOUT
char* uline; // NCSTYLE_UNDERLINK
char* reverse; // NCSTYLE_REVERSE
char* blink; // NCSTYLE_BLINK
char* dim; // NCSTYLE_DIM
char* italics; // NCSTYLE_ITALIC
char* italoff; // NCSTYLE_ITALIC (disable)
char* struck; // NCSTYLE_STRUCK
@ -117,7 +112,13 @@ typedef struct tinfo {
bool CCCflag; // "CCC" flag for palette set capability
bool BCEflag; // "BCE" flag for erases with background color
bool AMflag; // "AM" flag for automatic movement to next line
bool bold; // can we do bold via sgr?
// FIXME replace these with a single unsigned bitfield directly returned
bool bold; // NCSTYLE_BOLD via sgr?
bool standout; // NCSTYLE_STANDOUT via sgr?
bool uline; // NCSTYLE_UNDERLINE via sgr?
bool reverse; // NCSTYLE_REVERSE via sgr?
bool blink; // NCSTYLE_BLINK via sgr?
bool dim; // NCSTYLE_DIM via sgr?
// assigned based off nl_langinfo() in notcurses_core_init()
bool utf8; // are we using utf-8 encoding, as hoped?

@ -149,7 +149,7 @@ grow_esc_table(tinfo* ti, const char* tstr, escape_e esc,
size_t slen = strlen(tstr) + 1; // count the nul term
if(*tlen - *tused < slen){
// guaranteed to give us enough space to add tstr (and then some)
size_t newsize = *tlen + 4096 + slen;
size_t newsize = *tlen + 4020 + slen; // don't pull two pages ideally
char* tmp = realloc(ti->esctable, newsize);
if(tmp == NULL){
return -1;
@ -244,18 +244,28 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname,
}
}
}
terminfostr(&ti->standout, "smso"); // begin standout mode
terminfostr(&ti->uline, "smul"); // begin underline mode
terminfostr(&ti->reverse, "rev"); // begin reverse video mode
terminfostr(&ti->blink, "blink"); // turn on blinking
terminfostr(&ti->dim, "dim"); // turn on half-bright mode
// we don't actually use the bold capability -- we use sgr exclusively.
// but we use the presence of the bold capability to determine whether
// we think sgr supports bold, which...might be valid? i'm unsure.
char* bold;
if(terminfostr(&bold, "bold") == 0){
char* escstyle;
if(terminfostr(&escstyle, "bold") == 0){
ti->bold = true;
}
if(terminfostr(&escstyle, "smso") == 0){
ti->standout = true;
}
if(terminfostr(&escstyle, "smul") == 0){
ti->uline = true;
}
if(terminfostr(&escstyle, "rev") == 0){
ti->reverse = true;
}
if(terminfostr(&escstyle, "blink") == 0){
ti->blink = true;
}
if(terminfostr(&escstyle, "dim") == 0){
ti->dim = true;
}
terminfostr(&ti->italics, "sitm"); // begin italic mode
terminfostr(&ti->italoff, "ritm"); // end italic mode
terminfostr(&ti->home, "home"); // home the cursor

Loading…
Cancel
Save