From ff6da4414581cab3fff722e07d6cddcddef86367 Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 14 Jun 2021 02:18:24 -0400 Subject: [PATCH] direct mode: support undercurl throughout #1758 --- include/notcurses/notcurses.h | 8 ++++---- src/lib/direct.c | 12 +++++++++++- src/lib/termdesc.c | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 1d1b43f1f9..c84913dfc1 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -663,7 +663,10 @@ API int nccell_duplicate(struct ncplane* n, nccell* targ, const nccell* c); // Release resources held by the nccell 'c'. API void nccell_release(struct ncplane* n, nccell* c); -#define NCSTYLE_MASK 0x03ffu +#define NCSTYLE_MASK 0x07ffu +#define NCSTYLE_UNDERCURL 0x0400u +#define NCSTYLE_STRUCK 0x0200u +#define NCSTYLE_ITALIC 0x0100u #define NCSTYLE_STANDOUT 0x0080u #define NCSTYLE_UNDERLINE 0x0040u #define NCSTYLE_REVERSE 0x0020u @@ -672,9 +675,6 @@ API void nccell_release(struct ncplane* n, nccell* c); #define NCSTYLE_BOLD 0x0004u #define NCSTYLE_INVIS 0x0002u #define NCSTYLE_PROTECT 0x0001u -#define NCSTYLE_ITALIC 0x0100u -#define NCSTYLE_STRUCK 0x0200u -#define NCSTYLE_UNDERCURL 0x0400u #define NCSTYLE_NONE 0 // Set the specified style bits for the nccell 'c', whether they're actively diff --git a/src/lib/direct.c b/src/lib/direct.c index 3dc776e5ff..21b7a73e81 100644 --- a/src/lib/direct.c +++ b/src/lib/direct.c @@ -920,7 +920,7 @@ int ncdirect_on_styles(ncdirect* n, unsigned stylebits){ } if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_UNDERCURL, get_escape(&n->tcache, ESCAPE_SMULX), - get_escape(&n->tcache, ESCAPE_RMXX))){ + get_escape(&n->tcache, ESCAPE_SMULNOX))){ return -1; } n->stylemask = stylemask; @@ -951,6 +951,11 @@ int ncdirect_off_styles(ncdirect* n, unsigned stylebits){ get_escape(&n->tcache, ESCAPE_RMXX))){ return -1; } + if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_UNDERCURL, + get_escape(&n->tcache, ESCAPE_SMULX), + get_escape(&n->tcache, ESCAPE_SMULNOX))){ + return -1; + } n->stylemask = stylemask; return 0; } @@ -981,6 +986,11 @@ int ncdirect_set_styles(ncdirect* n, unsigned stylebits){ get_escape(&n->tcache, ESCAPE_RMXX))){ return -1; } + if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_UNDERCURL, + get_escape(&n->tcache, ESCAPE_SMULX), + get_escape(&n->tcache, ESCAPE_SMULNOX))){ + return -1; + } n->stylemask = stylemask; return 0; } diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index ad0c51a231..d7cce6095f 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -143,6 +143,7 @@ add_smulx_escapes(tinfo* ti, size_t* tablelen, size_t* tableused){ grow_esc_table(ti, "\x1b[4:0m", ESCAPE_SMULNOX, tablelen, tableused)){ return -1; } + ti->supported_styles |= NCSTYLE_UNDERCURL; return 0; }