term_debug: move style code into notcurses-info #1793

pull/1825/head
nick black 3 years ago
parent 0e9641e0f5
commit 8a98a98b7e
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -50,6 +50,34 @@ unicodedumper(FILE* fp, tinfo* ti){
return 0;
}
static void
tinfo_debug_style(const tinfo* ti, FILE* fp, const char* name, int esc, int deesc){
const char* code = get_escape(ti, esc);
if(code){
term_emit(code, fp, false);
}
fprintf(fp, "%s", name);
if(code){
code = get_escape(ti, deesc);
term_emit(code, fp, false);
}
}
static void
tinfo_debug_styles(const tinfo* ti, FILE* debugfp, const char* indent){
fprintf(debugfp, "%s", indent);
tinfo_debug_style(ti, debugfp, "bold", ESCAPE_BOLD, ESCAPE_SGR0);
fprintf(debugfp, " ");
tinfo_debug_style(ti, debugfp, "ital", ESCAPE_SITM, ESCAPE_RITM);
fprintf(debugfp, " ");
tinfo_debug_style(ti, debugfp, "struck", ESCAPE_SMXX, ESCAPE_RMXX);
fprintf(debugfp, " ");
tinfo_debug_style(ti, debugfp, "ucurl", ESCAPE_SMULX, ESCAPE_SMULNOX);
fprintf(debugfp, " ");
tinfo_debug_style(ti, debugfp, "uline", ESCAPE_SMUL, ESCAPE_RMUL);
fprintf(debugfp, "\n");
}
int main(void){
char* mbuf = NULL;
size_t len = 0;
@ -68,6 +96,7 @@ int main(void){
return EXIT_FAILURE;
}
notcurses_debug_caps(nc, mstream);
tinfo_debug_styles(&nc->tcache, mstream, " ");
unicodedumper(mstream, &nc->tcache);
if(fclose(mstream)){
notcurses_stop(nc);

@ -16,41 +16,6 @@ capyn(const tinfo* ti, const char* cap){
return capbool(ti, cap);
}
static void
tinfo_debug_uline(const tinfo* ti, FILE* debugfp){
const char* smul = get_escape(ti, ESCAPE_SMUL);
if(smul){
term_emit(smul, debugfp, false);
}
fprintf(debugfp, "uline");
if(smul){
const char* rmul = get_escape(ti, ESCAPE_RMUL);
term_emit(rmul, debugfp, false);
}
}
static void
tinfo_debug_ucurl(const tinfo* ti, FILE* debugfp){
const char* smulx = get_escape(ti, ESCAPE_SMULX);
if(smulx){
term_emit(smulx, debugfp, false);
}
fprintf(debugfp, "ucurl");
if(smulx){
const char* smulnox = get_escape(ti, ESCAPE_SMULNOX);
term_emit(smulnox, debugfp, false);
}
}
static void
tinfo_debug_styles(const tinfo* ti, FILE* debugfp, const char* indent){
fprintf(debugfp, "%s", indent);
tinfo_debug_ucurl(ti, debugfp);
fprintf(debugfp, " ");
tinfo_debug_uline(ti, debugfp);
fprintf(debugfp, "\n");
}
static void
tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols,
unsigned images, unsigned videos){
@ -83,7 +48,6 @@ tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols,
}else{
fprintf(debugfp, "%srgba pixel graphics supported\n", indent);
}
tinfo_debug_styles(ti, debugfp, indent);
fprintf(debugfp, "%sutf8%lc quad%lc sex%lc braille%lc images%lc videos%lc\n",
indent,
capbool(ti, ti->caps.utf8),

@ -607,8 +607,8 @@ term_setstyles(FILE* out, notcurses* nc, const nccell* c){
normalized = true;
}
}
// sgr will blow away italics/struck if they were set beforehand
nc->rstate.curattr &= ~(NCSTYLE_ITALIC | NCSTYLE_STRUCK);
// sgr will blow away non-sgr properties if they were set beforehand
nc->rstate.curattr &= ~(NCSTYLE_ITALIC | NCSTYLE_STRUCK | NCSTYLE_UNDERCURL);
}
ret |= term_setstyle(out, nc->rstate.curattr, cellattr, NCSTYLE_ITALIC,
get_escape(&nc->tcache, ESCAPE_SITM),

@ -362,6 +362,7 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8,
{ ESCAPE_SGR0, "sgr0", },
{ ESCAPE_SITM, "sitm", },
{ ESCAPE_RITM, "ritm", },
{ ESCAPE_BOLD, "bold", },
{ ESCAPE_CUD, "cud", },
{ ESCAPE_CUU, "cuu", },
{ ESCAPE_CUF, "cuf", },

@ -44,6 +44,7 @@ typedef enum {
ESCAPE_CUU, // "cuu" move n cells up
ESCAPE_CUB, // "cub" move n cells back (left)
ESCAPE_CUF, // "cuf" move n cells forward (right)
ESCAPE_BOLD, // "bold" enter bold mode
ESCAPE_CUD, // "cud" move n cells down
ESCAPE_CUF1, // "cuf1" move 1 cell forward (right)
ESCAPE_SMKX, // "smkx" keypad_xmit (keypad transmit mode)

Loading…
Cancel
Save