diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 2cca02ff7..62201f452 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -615,6 +615,7 @@ API void cell_release(struct ncplane* n, cell* c); #define NCSTYLE_INVIS 0x0002u #define NCSTYLE_PROTECT 0x0001u #define NCSTYLE_ITALIC 0x0100u +#define NCSTYLE_STRUCK 0x0200u #define NCSTYLE_NONE 0 // Set the specified style bits for the cell 'c', whether they're actively diff --git a/src/lib/direct.cpp b/src/lib/direct.cpp index c4f43c417..625607059 100644 --- a/src/lib/direct.cpp +++ b/src/lib/direct.cpp @@ -643,10 +643,15 @@ int ncdirect_styles_on(ncdirect* n, unsigned stylebits){ uint32_t stylemask = n->stylemask | stylebits; if(ncdirect_style_emit(n, n->tcache.sgr, stylemask, n->ttyfp) == 0){ if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC, - n->tcache.italics, n->tcache.italoff) == 0){ - n->stylemask = stylemask; + n->tcache.italics, n->tcache.italoff)){ 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; } @@ -656,10 +661,15 @@ int ncdirect_styles_off(ncdirect* n, unsigned stylebits){ uint32_t stylemask = n->stylemask & ~stylebits; if(ncdirect_style_emit(n, n->tcache.sgr, stylemask, n->ttyfp) == 0){ if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC, - n->tcache.italics, n->tcache.italoff) == 0){ - n->stylemask = stylemask; - return 0; + n->tcache.italics, n->tcache.italoff)){ + return -1; + } + 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; } @@ -669,10 +679,15 @@ int ncdirect_styles_set(ncdirect* n, unsigned stylebits){ uint32_t stylemask = stylebits; if(ncdirect_style_emit(n, n->tcache.sgr, stylemask, n->ttyfp) == 0){ if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC, - n->tcache.italics, n->tcache.italoff) == 0){ - n->stylemask = stylemask; - return 0; + n->tcache.italics, n->tcache.italoff)){ + return -1; } + 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; } diff --git a/src/lib/internal.h b/src/lib/internal.h index 2d683c719..a23c73916 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -237,14 +237,16 @@ typedef struct tinfo { char* cnorm; // restore cursor to default state char* hpa; // horizontal position adjusment (move cursor on row) char* vpa; // vertical position adjustment (move cursor on column) - char* standout; // CELL_STYLE_STANDOUT - char* uline; // CELL_STYLE_UNDERLINK - char* reverse; // CELL_STYLE_REVERSE - char* blink; // CELL_STYLE_BLINK - char* dim; // CELL_STYLE_DIM - char* bold; // CELL_STYLE_BOLD - char* italics; // CELL_STYLE_ITALIC - char* italoff; // CELL_STYLE_ITALIC (disable) + char* standout; // NCSTYLE_STANDOUT + char* uline; // NCSTYLE_UNDERLINK + char* reverse; // NCSTYLE_REVERSE + char* blink; // NCSTYLE_BLINK + char* dim; // NCSTYLE_DIM + char* bold; // NCSTYLE_BOLD + 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 char* oc; // restore original colors char* clearscr; // erase screen and home cursor diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index b660c7f9b..05f2b971d 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -1624,6 +1624,7 @@ unsigned notcurses_supported_styles(const notcurses* nc){ styles |= nc->tcache.dim ? NCSTYLE_DIM : 0; styles |= nc->tcache.bold ? NCSTYLE_BOLD : 0; styles |= nc->tcache.italics ? NCSTYLE_ITALIC : 0; + styles |= nc->tcache.struck ? NCSTYLE_STRUCK : 0; return styles; } diff --git a/src/lib/terminfo.c b/src/lib/terminfo.c index ad48e4b00..42df9727f 100644 --- a/src/lib/terminfo.c +++ b/src/lib/terminfo.c @@ -144,5 +144,9 @@ int interrogate_terminfo(tinfo* ti){ 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; } diff --git a/src/poc/sgr-direct.c b/src/poc/sgr-direct.c index c92de23aa..fd994ebcb 100644 --- a/src/poc/sgr-direct.c +++ b/src/poc/sgr-direct.c @@ -13,7 +13,7 @@ int main(void){ return EXIT_FAILURE; } 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)){ ncdirect_stop(nc); return EXIT_FAILURE; diff --git a/src/poc/sgr.c b/src/poc/sgr.c index e6cf1cfc6..c9622c67c 100644 --- a/src/poc/sgr.c +++ b/src/poc/sgr.c @@ -50,7 +50,7 @@ int main(int argc, char** argv){ --pivot; } int sgrcount = pivot + 1; - // generate all values + // generate all values, like a beast int cols = 0; while(pivot >= 0){ int i;