From 2ed1ad466fee4a8f604605af74f5619e9e9d39ff Mon Sep 17 00:00:00 2001 From: nick black Date: Wed, 23 Jun 2021 19:17:19 -0400 Subject: [PATCH] term_debug_caps: move big unicode block to notcurses-info #1793 --- CMakeLists.txt | 4 +++- include/notcurses/ncseqs.h | 24 +++++++++++++++++++++++ src/info/main.c | 31 ++++++++++++++++++++++++++++++ src/lib/blit.c | 39 +++++--------------------------------- src/lib/debug.c | 31 ++---------------------------- src/lib/internal.h | 2 -- src/lib/termdesc.c | 2 ++ src/lib/termdesc.h | 1 + 8 files changed, 68 insertions(+), 66 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41e4ebd2c..7b0600e10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -557,9 +557,11 @@ target_link_libraries(notcurses-demo ############################################################################ # notcurses-info file(GLOB INFOSRCS CONFIGURE_DEPENDS src/info/*.c) -add_executable(notcurses-info ${INFOSRCS}) +add_executable(notcurses-info ${INFOSRCS} ${COMPATSRC}) target_include_directories(notcurses-info PRIVATE + src + src/lib include "${CMAKE_REQUIRED_INCLUDES}" "${PROJECT_BINARY_DIR}/include" diff --git a/include/notcurses/ncseqs.h b/include/notcurses/ncseqs.h index 0af5a44e1..8bab8fc4d 100644 --- a/include/notcurses/ncseqs.h +++ b/include/notcurses/ncseqs.h @@ -18,6 +18,30 @@ extern "C" { #define NCBOXDOUBLEW L"╔╗╚╝═║" #define NCBOXASCIIW L"/\\\\/-|" +// symbols for legacy computing +#define NCEIGHTSUP "█🮆🮅🮄▀🮃🮂▔ " +#define NCHALFBLOCKS L" ▀▄█" +#define NCQUADBLOCKS L" ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█" +#define NCSEXBLOCKS L" 🬀🬁🬂🬃🬄🬅🬆🬇🬈🬊🬋🬌🬍🬎🬏🬐🬑🬒🬓▌🬔🬕🬖🬗🬘🬙🬚🬛🬜🬝🬞🬟🬠🬡🬢🬣🬤🬥🬦🬧▐🬨🬩🬪🬫🬬🬭🬮🬯🬰🬱🬲🬳🬴🬵🬶🬷🬸🬹🬺🬻█" +#define NCBRAILLEEGCS \ + L"\u2800\u2801\u2808\u2809\u2802\u2803\u280a\u280b\u2810\u2811\u2818\u2819\u2812\u2813\u281a\u281b"\ + "\u2804\u2805\u280c\u280d\u2806\u2807\u280e\u280f\u2814\u2815\u281c\u281d\u2816\u2817\u281e\u281f"\ + "\u2820\u2821\u2828\u2829\u2822\u2823\u282a\u282b\u2830\u2831\u2838\u2839\u2832\u2833\u283a\u283b"\ + "\u2824\u2825\u282c\u282d\u2826\u2827\u282e\u282f\u2834\u2835\u283c\u283d\u2836\u2837\u283e\u283f"\ + "\u2840\u2841\u2848\u2849\u2842\u2843\u284a\u284b\u2850\u2851\u2858\u2859\u2852\u2853\u285a\u285b"\ + "\u2844\u2845\u284c\u284d\u2846\u2847\u284e\u284f\u2854\u2855\u285c\u285d\u2856\u2857\u285e\u285f"\ + "\u2860\u2861\u2868\u2869\u2862\u2863\u286a\u286b\u2870\u2871\u2878\u2879\u2872\u2873\u287a\u287b"\ + "\u2864\u2865\u286c\u286d\u2866\u2867\u286e\u286f\u2874\u2875\u287c\u287d\u2876\u2877\u287e\u287f"\ + "\u2880\u2881\u2888\u2889\u2882\u2883\u288a\u288b\u2890\u2891\u2898\u2899\u2892\u2893\u289a\u289b"\ + "\u2884\u2885\u288c\u288d\u2886\u2887\u288e\u288f\u2894\u2895\u289c\u289d\u2896\u2897\u289e\u289f"\ + "\u28a0\u28a1\u28a8\u28a9\u28a2\u28a3\u28aa\u28ab\u28b0\u28b1\u28b8\u28b9\u28b2\u28b3\u28ba\u28bb"\ + "\u28a4\u28a5\u28ac\u28ad\u28a6\u28a7\u28ae\u28af\u28b4\u28b5\u28bc\u28bd\u28b6\u28b7\u28be\u28bf"\ + "\u28c0\u28c1\u28c8\u28c9\u28c2\u28c3\u28ca\u28cb\u28d0\u28d1\u28d8\u28d9\u28d2\u28d3\u28da\u28db"\ + "\u28c4\u28c5\u28cc\u28cd\u28c6\u28c7\u28ce\u28cf\u28d4\u28d5\u28dc\u28dd\u28d6\u28d7\u28de\u28df"\ + "\u28e0\u28e1\u28e8\u28e9\u28e2\u28e3\u28ea\u28eb\u28f0\u28f1\u28f8\u28f9\u28f2\u28f3\u28fa\u28fb"\ + "\u28e4\u28e5\u28ec\u28ed\u28e6\u28e7\u28ee\u28ef\u28f4\u28f5\u28fc\u28fd\u28f6\u28f7\u28fe\u28ff" +#define NCEIGHTHSBOTTOM L" ▁▂▃▄▅▆▇█" + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/info/main.c b/src/info/main.c index c79a1b728..be998ef5a 100644 --- a/src/info/main.c +++ b/src/info/main.c @@ -2,6 +2,7 @@ #include #include #include +#include "internal.h" // internal headers // write(2) with retry on partial write or interrupted write static inline ssize_t @@ -20,6 +21,35 @@ writen(int fd, const void* buf, size_t len){ return w; } +static int +unicodedumper(FILE* fp, tinfo* ti){ + if(ti->caps.utf8){ + fprintf(fp, " {%ls} {%ls} ⎧%.122ls⎫ ⎧█ ⎫ 🯰🯱\n", + NCHALFBLOCKS, NCQUADBLOCKS, NCSEXBLOCKS); + fprintf(fp, " ⎩%ls⎭ ⎪🮋▏⎪ 🯲🯳\n", + NCSEXBLOCKS + 32); + fprintf(fp, " ⎧%.6ls%.3ls⎫ ⎧%.6ls%.3ls⎫ ⎧%.6ls%.3ls⎫ ⎧%.6ls%.3ls⎫ ⎪🮊▎⎪ 🯴🯵\n", + NCBOXLIGHTW, NCBOXLIGHTW + 4, + NCBOXHEAVYW, NCBOXHEAVYW + 4, + NCBOXROUNDW, NCBOXROUNDW + 4, + NCBOXDOUBLEW, NCBOXDOUBLEW + 4); + fprintf(fp, " ⎩%.6ls%.3ls⎭ ⎩%.6ls%.3ls⎭ ⎩%.6ls%.3ls⎭ ⎩%.6ls%.3ls⎭ ⎪🮉▍⎪ 🯶🯷\n", + NCBOXLIGHTW + 2, NCBOXLIGHTW + 5, + NCBOXHEAVYW + 2, NCBOXHEAVYW + 5, + NCBOXROUNDW + 2, NCBOXROUNDW + 5, + NCBOXDOUBLEW + 2, NCBOXDOUBLEW + 5); + fprintf(fp, " ⎡%.192ls⎤ ⎨▐▌⎬ 🯸🯹\n", NCBRAILLEEGCS); + fprintf(fp, " ⎢%.192ls⎥ ⎪🮈▋⎪\n", NCBRAILLEEGCS + 64); + fprintf(fp, " ⎢%.192ls⎥ ⎪🮇▊⎪\n", NCBRAILLEEGCS + 128); + fprintf(fp, " ⎣%.192ls⎦ ⎪▕▉⎪\n", NCBRAILLEEGCS + 192); + fprintf(fp, " ⎛%ls⎞ ▔🭶🭷🭸🭹🭺🭻▁ 🭁 🭂 🭃 🭄 🭅 🭆 🭑 🭐 🭏 🭎 🭍 🭌 🭆🭑 🭄🭏 🭅🭐 🭃🭎 🭂🭍 🭁🭌 🭨🭪 ⎩ █⎭\n", + NCEIGHTHSBOTTOM); + fprintf(fp, " ⎝%s⎠ ▏🭰🭱🭲🭳🭴🭵▕ 🭒 🭓 🭔 🭕 🭖 🭧 🭜 🭟 🭠 🭡 🭞 🭝 🭧🭜 🭕🭠 🭖🭡 🭔🭟 🭓🭞 🭒🭝 🭪🭨 \n", + NCEIGHTSUP); + } + return 0; +} + int main(void){ char* mbuf = NULL; size_t len = 0; @@ -38,6 +68,7 @@ int main(void){ return EXIT_FAILURE; } notcurses_debug_caps(nc, mstream); + unicodedumper(mstream, &nc->tcache); if(fclose(mstream)){ notcurses_stop(nc); fprintf(stderr, "Error closing memstream after %zuB\n", len); diff --git a/src/lib/blit.c b/src/lib/blit.c index dc1bae50f..6bdad8415 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -883,33 +883,16 @@ static struct blitset notcurses_blitters[] = { .egcs = L" █", .plotegcs = L" █", .blit = tria_blit_ascii,.name = "ascii", .fill = false, }, { .geom = NCBLIT_2x1, .width = 1, .height = 2, - .egcs = L" ▀▄█", .plotegcs = L" ▄█", + .egcs = NCHALFBLOCKS, .plotegcs = L" ▄█", .blit = tria_blit, .name = "half", .fill = false, }, { .geom = NCBLIT_2x2, .width = 2, .height = 2, - .egcs = L" ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█", .plotegcs = L" ▗▐▖▄▟▌▙█", + .egcs = NCQUADBLOCKS, .plotegcs = L" ▗▐▖▄▟▌▙█", .blit = quadrant_blit, .name = "quad", .fill = false, }, { .geom = NCBLIT_3x2, .width = 2, .height = 3, - .egcs = L" 🬀🬁🬂🬃🬄🬅🬆🬇🬈🬊🬋🬌🬍🬎🬏🬐🬑🬒🬓▌🬔🬕🬖🬗🬘🬙🬚🬛🬜🬝🬞🬟🬠🬡🬢🬣🬤🬥🬦🬧▐🬨🬩🬪🬫🬬🬭🬮🬯🬰🬱🬲🬳🬴🬵🬶🬷🬸🬹🬺🬻█", - .plotegcs = L" 🬞🬦▐🬏🬭🬵🬷🬓🬱🬹🬻▌🬲🬺█", + .egcs = NCSEXBLOCKS, .plotegcs = L" 🬞🬦▐🬏🬭🬵🬷🬓🬱🬹🬻▌🬲🬺█", .blit = sextant_blit, .name = "sex", .fill = false, }, { .geom = NCBLIT_BRAILLE, .width = 2, .height = 4, - .egcs = - L"\u2800\u2801\u2808\u2809\u2802\u2803\u280a\u280b\u2810\u2811\u2818\u2819\u2812\u2813\u281a\u281b" - "\u2804\u2805\u280c\u280d\u2806\u2807\u280e\u280f\u2814\u2815\u281c\u281d\u2816\u2817\u281e\u281f" - "\u2820\u2821\u2828\u2829\u2822\u2823\u282a\u282b\u2830\u2831\u2838\u2839\u2832\u2833\u283a\u283b" - "\u2824\u2825\u282c\u282d\u2826\u2827\u282e\u282f\u2834\u2835\u283c\u283d\u2836\u2837\u283e\u283f" - "\u2840\u2841\u2848\u2849\u2842\u2843\u284a\u284b\u2850\u2851\u2858\u2859\u2852\u2853\u285a\u285b" - "\u2844\u2845\u284c\u284d\u2846\u2847\u284e\u284f\u2854\u2855\u285c\u285d\u2856\u2857\u285e\u285f" - "\u2860\u2861\u2868\u2869\u2862\u2863\u286a\u286b\u2870\u2871\u2878\u2879\u2872\u2873\u287a\u287b" - "\u2864\u2865\u286c\u286d\u2866\u2867\u286e\u286f\u2874\u2875\u287c\u287d\u2876\u2877\u287e\u287f" - "\u2880\u2881\u2888\u2889\u2882\u2883\u288a\u288b\u2890\u2891\u2898\u2899\u2892\u2893\u289a\u289b" - "\u2884\u2885\u288c\u288d\u2886\u2887\u288e\u288f\u2894\u2895\u289c\u289d\u2896\u2897\u289e\u289f" - "\u28a0\u28a1\u28a8\u28a9\u28a2\u28a3\u28aa\u28ab\u28b0\u28b1\u28b8\u28b9\u28b2\u28b3\u28ba\u28bb" - "\u28a4\u28a5\u28ac\u28ad\u28a6\u28a7\u28ae\u28af\u28b4\u28b5\u28bc\u28bd\u28b6\u28b7\u28be\u28bf" - "\u28c0\u28c1\u28c8\u28c9\u28c2\u28c3\u28ca\u28cb\u28d0\u28d1\u28d8\u28d9\u28d2\u28d3\u28da\u28db" - "\u28c4\u28c5\u28cc\u28cd\u28c6\u28c7\u28ce\u28cf\u28d4\u28d5\u28dc\u28dd\u28d6\u28d7\u28de\u28df" - "\u28e0\u28e1\u28e8\u28e9\u28e2\u28e3\u28ea\u28eb\u28f0\u28f1\u28f8\u28f9\u28f2\u28f3\u28fa\u28fb" - "\u28e4\u28e5\u28ec\u28ed\u28e6\u28e7\u28ee\u28ef\u28f4\u28f5\u28fc\u28fd\u28f6\u28f7\u28fe\u28ff", + .egcs = NCBRAILLEEGCS, .plotegcs = L"⠀⢀⢠⢰⢸⡀⣀⣠⣰⣸⡄⣄⣤⣴⣼⡆⣆⣦⣶⣾⡇⣇⣧⣷⣿", .blit = braille_blit, .name = "braille", .fill = true, }, { .geom = NCBLIT_PIXEL, .width = 1, .height = 1, @@ -919,25 +902,13 @@ static struct blitset notcurses_blitters[] = { .egcs = NULL, .plotegcs = L" ▂▄▆█", .blit = tria_blit, .name = "fourstep", .fill = false, }, { .geom = NCBLIT_8x1, .width = 1, .height = 8, - .egcs = NULL, .plotegcs = L" ▁▂▃▄▅▆▇█", + .egcs = NULL, .plotegcs = NCEIGHTHSBOTTOM, .blit = tria_blit, .name = "eightstep", .fill = false, }, { .geom = 0, .width = 0, .height = 0, .egcs = NULL, .plotegcs = NULL, .blit = NULL, .name = NULL, .fill = false, }, }; -const wchar_t* -get_blitter_egcs(ncblitter_e id){ - if(id == NCBLIT_DEFAULT){ - return NULL; - } - // prefer the egcs set, but return plotegcs otherwise - if(notcurses_blitters[id - 1].egcs){ - return notcurses_blitters[id - 1].egcs; - } - return notcurses_blitters[id - 1].plotegcs; -} - void set_pixel_blitter(ncblitter blitfxn){ struct blitset* b = notcurses_blitters; while(b->geom != NCBLIT_PIXEL){ diff --git a/src/lib/debug.c b/src/lib/debug.c index b02ac7733..0e595b524 100644 --- a/src/lib/debug.c +++ b/src/lib/debug.c @@ -5,9 +5,9 @@ int loglevel = NCLOGLEVEL_SILENT; static inline wchar_t capbool(const tinfo* ti, bool cap){ if(ti->caps.utf8){ - return cap ? L'✅' : L'❌'; + return cap ? L'✓' : L'✖'; }else{ - return cap ? 'Y' : 'N'; + return cap ? '+' : '-'; } } @@ -93,33 +93,6 @@ tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols, capbool(ti, ti->caps.braille), capbool(ti, images), capbool(ti, videos)); - if(ti->caps.utf8){ - fprintf(debugfp, "%s{%ls} {%ls} ⎧%.122ls⎫ ⎧█ ⎫ 🯰🯱\n", indent, - get_blitter_egcs(NCBLIT_2x1), get_blitter_egcs(NCBLIT_2x2), - get_blitter_egcs(NCBLIT_3x2)); - fprintf(debugfp, "%s ⎩%ls⎭ ⎪🮋▏⎪ 🯲🯳\n", indent, - get_blitter_egcs(NCBLIT_3x2) + 32); - fprintf(debugfp, "%s⎧%.6ls%.3ls⎫ ⎧%.6ls%.3ls⎫ ⎧%.6ls%.3ls⎫ ⎧%.6ls%.3ls⎫ ⎪🮊▎⎪ 🯴🯵\n", indent, - NCBOXLIGHTW, NCBOXLIGHTW + 4, - NCBOXHEAVYW, NCBOXHEAVYW + 4, - NCBOXROUNDW, NCBOXROUNDW + 4, - NCBOXDOUBLEW, NCBOXDOUBLEW + 4); - fprintf(debugfp, "%s⎩%.6ls%.3ls⎭ ⎩%.6ls%.3ls⎭ ⎩%.6ls%.3ls⎭ ⎩%.6ls%.3ls⎭ ⎪🮉▍⎪ 🯶🯷\n", indent, - NCBOXLIGHTW + 2, NCBOXLIGHTW + 5, - NCBOXHEAVYW + 2, NCBOXHEAVYW + 5, - NCBOXROUNDW + 2, NCBOXROUNDW + 5, - NCBOXDOUBLEW + 2, NCBOXDOUBLEW + 5); - fprintf(debugfp, "%s⎡%.192ls⎤ ⎨▐▌⎬ 🯸🯹\n", indent, - get_blitter_egcs(NCBLIT_BRAILLE)); - fprintf(debugfp, "%s⎢%.192ls⎥ ⎪🮈▋⎪\n", indent, - get_blitter_egcs(NCBLIT_BRAILLE) + 64); - fprintf(debugfp, "%s⎢%.192ls⎥ ⎪🮇▊⎪\n", indent, - get_blitter_egcs(NCBLIT_BRAILLE) + 128); - fprintf(debugfp, "%s⎣%.192ls⎦ ⎪▕▉⎪\n", indent, - get_blitter_egcs(NCBLIT_BRAILLE) + 192); - fprintf(debugfp, "%s ⎛%ls⎞ ▔🭶🭷🭸🭹🭺🭻▁ 🭁 🭂 🭃 🭄 🭅 🭆 🭑 🭐 🭏 🭎 🭍 🭌 🭆🭑 🭄🭏 🭅🭐 🭃🭎 🭂🭍 🭁🭌 🭨🭪 ⎩ █⎭\n", indent, get_blitter_egcs(NCBLIT_8x1)); - fprintf(debugfp, "%s ⎝%s⎠ ▏🭰🭱🭲🭳🭴🭵▕ 🭒 🭓 🭔 🭕 🭖 🭧 🭜 🭟 🭠 🭡 🭞 🭝 🭧🭜 🭕🭠 🭖🭡 🭔🭟 🭓🭞 🭒🭝 🭪🭨 \n", indent, "█🮆🮅🮄▀🮃🮂▔ "); - } fprintf(debugfp, "%sbackground of 0x%06lx is %sconsidered transparent\n", indent, ti->bg_collides_default & 0xfffffful, (ti->bg_collides_default & 0x01000000) ? "" : "not "); } diff --git a/src/lib/internal.h b/src/lib/internal.h index 84cb58b30..895331d65 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -1604,8 +1604,6 @@ rgba_blitter_low(const tinfo* tcache, ncscale_e scale, bool maydegrade, return lookup_blitset(tcache, blitrec, maydegrade); } -const wchar_t* get_blitter_egcs(ncblitter_e id); - // RGBA visuals all use NCBLIT_2x1 by default (or NCBLIT_1x1 if not in // UTF-8 mode), but an alternative can be specified. static inline const struct blitset* diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index 4cf815696..58d23a331 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -1,5 +1,7 @@ #include +#include #include // needed for some definitions, see terminfo(3ncurses) +#include #include #include "internal.h" #include "input.h" diff --git a/src/lib/termdesc.h b/src/lib/termdesc.h index 38f619bda..93c76f1e5 100644 --- a/src/lib/termdesc.h +++ b/src/lib/termdesc.h @@ -9,6 +9,7 @@ extern "C" { #include "input.h" #include +#include struct ncpile; struct sprixel;