add NCSTYLE_STRUCK #1138

pull/1145/head
nick black 4 years ago committed by Nick Black
parent b33c780c88
commit fe164b6210

@ -615,6 +615,7 @@ API void cell_release(struct ncplane* n, cell* c);
#define NCSTYLE_INVIS 0x0002u #define NCSTYLE_INVIS 0x0002u
#define NCSTYLE_PROTECT 0x0001u #define NCSTYLE_PROTECT 0x0001u
#define NCSTYLE_ITALIC 0x0100u #define NCSTYLE_ITALIC 0x0100u
#define NCSTYLE_STRUCK 0x0200u
#define NCSTYLE_NONE 0 #define NCSTYLE_NONE 0
// Set the specified style bits for the cell 'c', whether they're actively // Set the specified style bits for the cell 'c', whether they're actively

@ -643,10 +643,15 @@ int ncdirect_styles_on(ncdirect* n, unsigned stylebits){
uint32_t stylemask = n->stylemask | stylebits; uint32_t stylemask = n->stylemask | stylebits;
if(ncdirect_style_emit(n, n->tcache.sgr, stylemask, n->ttyfp) == 0){ if(ncdirect_style_emit(n, n->tcache.sgr, stylemask, n->ttyfp) == 0){
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC, if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC,
n->tcache.italics, n->tcache.italoff) == 0){ n->tcache.italics, n->tcache.italoff)){
n->stylemask = stylemask;
return 0; return 0;
} }
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_STRUCK,
n->tcache.struck, n->tcache.struckoff)){
return -1;
}
n->stylemask = stylemask;
return 0;
} }
return -1; return -1;
} }
@ -656,10 +661,15 @@ int ncdirect_styles_off(ncdirect* n, unsigned stylebits){
uint32_t stylemask = n->stylemask & ~stylebits; uint32_t stylemask = n->stylemask & ~stylebits;
if(ncdirect_style_emit(n, n->tcache.sgr, stylemask, n->ttyfp) == 0){ if(ncdirect_style_emit(n, n->tcache.sgr, stylemask, n->ttyfp) == 0){
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC, if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC,
n->tcache.italics, n->tcache.italoff) == 0){ n->tcache.italics, n->tcache.italoff)){
n->stylemask = stylemask; return -1;
return 0; }
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_STRUCK,
n->tcache.struck, n->tcache.struckoff)){
return -1;
} }
n->stylemask = stylemask;
return 0;
} }
return -1; return -1;
} }
@ -669,10 +679,15 @@ int ncdirect_styles_set(ncdirect* n, unsigned stylebits){
uint32_t stylemask = stylebits; uint32_t stylemask = stylebits;
if(ncdirect_style_emit(n, n->tcache.sgr, stylemask, n->ttyfp) == 0){ if(ncdirect_style_emit(n, n->tcache.sgr, stylemask, n->ttyfp) == 0){
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC, if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC,
n->tcache.italics, n->tcache.italoff) == 0){ n->tcache.italics, n->tcache.italoff)){
n->stylemask = stylemask; return -1;
return 0;
} }
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_STRUCK,
n->tcache.struck, n->tcache.struckoff)){
return -1;
}
n->stylemask = stylemask;
return 0;
} }
return -1; return -1;
} }

@ -237,14 +237,16 @@ typedef struct tinfo {
char* cnorm; // restore cursor to default state char* cnorm; // restore cursor to default state
char* hpa; // horizontal position adjusment (move cursor on row) char* hpa; // horizontal position adjusment (move cursor on row)
char* vpa; // vertical position adjustment (move cursor on column) char* vpa; // vertical position adjustment (move cursor on column)
char* standout; // CELL_STYLE_STANDOUT char* standout; // NCSTYLE_STANDOUT
char* uline; // CELL_STYLE_UNDERLINK char* uline; // NCSTYLE_UNDERLINK
char* reverse; // CELL_STYLE_REVERSE char* reverse; // NCSTYLE_REVERSE
char* blink; // CELL_STYLE_BLINK char* blink; // NCSTYLE_BLINK
char* dim; // CELL_STYLE_DIM char* dim; // NCSTYLE_DIM
char* bold; // CELL_STYLE_BOLD char* bold; // NCSTYLE_BOLD
char* italics; // CELL_STYLE_ITALIC char* italics; // NCSTYLE_ITALIC
char* italoff; // CELL_STYLE_ITALIC (disable) char* italoff; // NCSTYLE_ITALIC (disable)
char* struck; // NCSTYLE_STRUCK
char* struckoff;// NCSTYLE_STRUCK (disable)
char* initc; // set a palette entry's RGB value char* initc; // set a palette entry's RGB value
char* oc; // restore original colors char* oc; // restore original colors
char* clearscr; // erase screen and home cursor char* clearscr; // erase screen and home cursor

@ -1624,6 +1624,7 @@ unsigned notcurses_supported_styles(const notcurses* nc){
styles |= nc->tcache.dim ? NCSTYLE_DIM : 0; styles |= nc->tcache.dim ? NCSTYLE_DIM : 0;
styles |= nc->tcache.bold ? NCSTYLE_BOLD : 0; styles |= nc->tcache.bold ? NCSTYLE_BOLD : 0;
styles |= nc->tcache.italics ? NCSTYLE_ITALIC : 0; styles |= nc->tcache.italics ? NCSTYLE_ITALIC : 0;
styles |= nc->tcache.struck ? NCSTYLE_STRUCK : 0;
return styles; return styles;
} }

@ -144,5 +144,9 @@ int interrogate_terminfo(tinfo* ti){
return -1; return -1;
} }
} }
// some control sequences are unavailable from terminfo, and we must instead
// hardcode them :/. use at your own peril!
ti->struck = "\x1b[9m";
ti->struckoff = "\x1b[29m";
return 0; return 0;
} }

@ -13,7 +13,7 @@ int main(void){
return EXIT_FAILURE; return EXIT_FAILURE;
} }
int e = 0; int e = 0;
for(unsigned i = 0 ; i < (NCSTYLE_ITALIC << 1u) ; ++i){ for(unsigned i = 0 ; i < (NCSTYLE_STRUCK << 1u) ; ++i){
if(ncdirect_styles_set(nc, i)){ if(ncdirect_styles_set(nc, i)){
ncdirect_stop(nc); ncdirect_stop(nc);
return EXIT_FAILURE; return EXIT_FAILURE;

@ -50,7 +50,7 @@ int main(int argc, char** argv){
--pivot; --pivot;
} }
int sgrcount = pivot + 1; int sgrcount = pivot + 1;
// generate all values // generate all values, like a beast
int cols = 0; int cols = 0;
while(pivot >= 0){ while(pivot >= 0){
int i; int i;

Loading…
Cancel
Save