debug_term: use unicode checks/xs when available

This commit is contained in:
nick black 2021-06-23 18:53:09 -04:00
parent ac652ac7f3
commit 42f9419006
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 35 additions and 25 deletions

View File

@ -69,7 +69,7 @@ endif()
# global compiler flags # global compiler flags
add_compile_definitions(FORTIFY_SOURCE=2) add_compile_definitions(FORTIFY_SOURCE=2)
add_compile_options(-Wall -Wextra -W -Wshadow -Wformat -Wno-nonnull-compare add_compile_options(-Wall -Wextra -W -Wshadow -Wformat -Wno-nonnull-compare
-Wformat-security -fexceptions) -Wformat-security -fexceptions -fstrict-aliasing)
message(STATUS "Requested multimedia engine: ${USE_MULTIMEDIA}") message(STATUS "Requested multimedia engine: ${USE_MULTIMEDIA}")
message(STATUS "Requested build mode: ${CMAKE_BUILD_TYPE}") message(STATUS "Requested build mode: ${CMAKE_BUILD_TYPE}")

View File

@ -2,14 +2,18 @@
int loglevel = NCLOGLEVEL_SILENT; int loglevel = NCLOGLEVEL_SILENT;
static inline char static inline wchar_t
capyn(const char* cap){ capbool(const tinfo* ti, bool cap){
return cap ? 'y' : 'n'; if(ti->caps.utf8){
return cap ? L'' : L'';
}else{
return cap ? 'Y' : 'N';
}
} }
static inline char static inline wchar_t
capbool(bool cap){ capyn(const tinfo* ti, const char* cap){
return cap ? 'y' : 'n'; return capbool(ti, cap);
} }
static void static void
@ -51,17 +55,23 @@ static void
tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols, tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols,
unsigned images, unsigned videos){ unsigned images, unsigned videos){
const char indent[] = " "; const char indent[] = " ";
fprintf(debugfp, "%scolors: %u rgb: %c ccc: %c setaf: %c setab: %c app-sync: %c\n", fprintf(debugfp, "%scolors: %u rgb%lc ccc%lc af%lc ab%lc appsync%lc u7%lc cup%lc vpa%lc hpa%lc\n",
indent, ti->caps.colors, capbool(ti->caps.rgb), capbool(ti->caps.can_change_colors), indent, ti->caps.colors,
capyn(get_escape(ti, ESCAPE_SETAF)), capbool(ti, ti->caps.rgb),
capyn(get_escape(ti, ESCAPE_SETAB)), capbool(ti, ti->caps.can_change_colors),
capyn(get_escape(ti, ESCAPE_BSU))); capyn(ti, get_escape(ti, ESCAPE_SETAF)),
fprintf(debugfp, "%ssgr: %c sgr0: %c op: %c fgop: %c bgop: %c\n", capyn(ti, get_escape(ti, ESCAPE_SETAB)),
indent, capyn(get_escape(ti, ESCAPE_SGR)), capyn(ti, get_escape(ti, ESCAPE_BSU)),
capyn(get_escape(ti, ESCAPE_SGR0)), capyn(ti, get_escape(ti, ESCAPE_DSRCPR)),
capyn(get_escape(ti, ESCAPE_OP)), capyn(ti, get_escape(ti, ESCAPE_CUP)),
capyn(get_escape(ti, ESCAPE_FGOP)), capyn(ti, get_escape(ti, ESCAPE_VPA)),
capyn(get_escape(ti, ESCAPE_BGOP))); capyn(ti, get_escape(ti, ESCAPE_HPA)));
fprintf(debugfp, "%ssgr%lc sgr0%lc op%lc fgop%lc bgop%lc\n",
indent, capyn(ti, get_escape(ti, ESCAPE_SGR)),
capyn(ti, get_escape(ti, ESCAPE_SGR0)),
capyn(ti, get_escape(ti, ESCAPE_OP)),
capyn(ti, get_escape(ti, ESCAPE_FGOP)),
capyn(ti, get_escape(ti, ESCAPE_BGOP)));
fprintf(debugfp, "%srows: %u cols: %u rpx: %u cpx: %u (%dx%d)\n", fprintf(debugfp, "%srows: %u cols: %u rpx: %u cpx: %u (%dx%d)\n",
indent, rows, cols, ti->cellpixy, ti->cellpixx, rows * ti->cellpixy, cols * ti->cellpixx); indent, rows, cols, ti->cellpixy, ti->cellpixx, rows * ti->cellpixy, cols * ti->cellpixx);
if(!ti->pixel_draw){ if(!ti->pixel_draw){
@ -76,9 +86,13 @@ tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols,
} }
tinfo_debug_styles(ti, debugfp, indent); tinfo_debug_styles(ti, debugfp, indent);
fprintf(debugfp, "%sutf8: %c quad: %c sex: %c braille: %c images: %c videos: %c\n", fprintf(debugfp, "%sutf8: %c quad: %c sex: %c braille: %c images: %c videos: %c\n",
indent, capbool(ti->caps.utf8), capbool(ti->caps.quadrants), indent,
capbool(ti->caps.sextants), capbool(ti->caps.braille), capbool(ti, ti->caps.utf8),
capbool(images), capbool(videos)); capbool(ti, ti->caps.quadrants),
capbool(ti, ti->caps.sextants),
capbool(ti, ti->caps.braille),
capbool(ti, images),
capbool(ti, videos));
if(ti->caps.utf8){ if(ti->caps.utf8){
fprintf(debugfp, "%s{%ls} {%ls} ⎧%.122ls⎫ ⎧█ ⎫ 🯰🯱\n", indent, fprintf(debugfp, "%s{%ls} {%ls} ⎧%.122ls⎫ ⎧█ ⎫ 🯰🯱\n", indent,
get_blitter_egcs(NCBLIT_2x1), get_blitter_egcs(NCBLIT_2x2), get_blitter_egcs(NCBLIT_2x1), get_blitter_egcs(NCBLIT_2x2),
@ -108,10 +122,6 @@ tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols,
} }
fprintf(debugfp, "%sbackground of 0x%06lx is %sconsidered transparent\n", indent, ti->bg_collides_default & 0xfffffful, fprintf(debugfp, "%sbackground of 0x%06lx is %sconsidered transparent\n", indent, ti->bg_collides_default & 0xfffffful,
(ti->bg_collides_default & 0x01000000) ? "" : "not "); (ti->bg_collides_default & 0x01000000) ? "" : "not ");
fprintf(debugfp, "%scup: %c vpa: %c hpa: %c\n",
indent, capyn(get_escape(ti, ESCAPE_CUP)),
capyn(get_escape(ti, ESCAPE_VPA)),
capyn(get_escape(ti, ESCAPE_HPA)));
} }
void notcurses_debug_caps(const notcurses* nc, FILE* debugfp){ void notcurses_debug_caps(const notcurses* nc, FILE* debugfp){