|
|
@ -4,23 +4,6 @@
|
|
|
|
#include <notcurses/notcurses.h>
|
|
|
|
#include <notcurses/notcurses.h>
|
|
|
|
#include "internal.h" // internal headers
|
|
|
|
#include "internal.h" // internal headers
|
|
|
|
|
|
|
|
|
|
|
|
// write(2) with retry on partial write or interrupted write
|
|
|
|
|
|
|
|
static inline ssize_t
|
|
|
|
|
|
|
|
writen(int fd, const void* buf, size_t len){
|
|
|
|
|
|
|
|
ssize_t r;
|
|
|
|
|
|
|
|
size_t w = 0;
|
|
|
|
|
|
|
|
while(w < len){
|
|
|
|
|
|
|
|
if((r = write(fd, (const char*)buf + w, len - w)) < 0){
|
|
|
|
|
|
|
|
if(errno == EAGAIN || errno == EBUSY || errno == EINTR){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
w += r;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return w;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static inline wchar_t
|
|
|
|
static inline wchar_t
|
|
|
|
capbool(const tinfo* ti, bool cap){
|
|
|
|
capbool(const tinfo* ti, bool cap){
|
|
|
|
if(ti->caps.utf8){
|
|
|
|
if(ti->caps.utf8){
|
|
|
@ -31,8 +14,8 @@ capbool(const tinfo* ti, bool cap){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
static int
|
|
|
|
unicodedumper(const struct notcurses* nc, FILE* fp, tinfo* ti, const char* indent){
|
|
|
|
unicodedumper(const struct notcurses* nc, struct ncplane* n, tinfo* ti, const char* indent){
|
|
|
|
fprintf(fp, "%sutf8%lc quad%lc sex%lc braille%lc images%lc videos%lc\n",
|
|
|
|
ncplane_printf(n, "%sutf8%lc quad%lc sex%lc braille%lc images%lc videos%lc\n",
|
|
|
|
indent,
|
|
|
|
indent,
|
|
|
|
capbool(ti, ti->caps.utf8),
|
|
|
|
capbool(ti, ti->caps.utf8),
|
|
|
|
capbool(ti, ti->caps.quadrants),
|
|
|
|
capbool(ti, ti->caps.quadrants),
|
|
|
@ -41,57 +24,51 @@ unicodedumper(const struct notcurses* nc, FILE* fp, tinfo* ti, const char* inden
|
|
|
|
capbool(ti, notcurses_canopen_images(nc)),
|
|
|
|
capbool(ti, notcurses_canopen_images(nc)),
|
|
|
|
capbool(ti, notcurses_canopen_videos(nc)));
|
|
|
|
capbool(ti, notcurses_canopen_videos(nc)));
|
|
|
|
if(ti->caps.utf8){
|
|
|
|
if(ti->caps.utf8){
|
|
|
|
fprintf(fp, " {%ls} {%ls} ⎧%.122ls⎫ ⎧█ ⎫ 🯰🯱\n",
|
|
|
|
ncplane_printf(n, " {%ls} {%ls} ⎧%.122ls⎫ ⎧█ ⎫ 🯰🯱\n",
|
|
|
|
NCHALFBLOCKS, NCQUADBLOCKS, NCSEXBLOCKS);
|
|
|
|
NCHALFBLOCKS, NCQUADBLOCKS, NCSEXBLOCKS);
|
|
|
|
fprintf(fp, " ⎩%ls⎭ ⎪🮋▏⎪ 🯲🯳\n",
|
|
|
|
ncplane_printf(n, " ⎩%ls⎭ ⎪🮋▏⎪ 🯲🯳\n",
|
|
|
|
NCSEXBLOCKS + 32);
|
|
|
|
NCSEXBLOCKS + 32);
|
|
|
|
fprintf(fp, " ⎧%.6ls%.3ls⎫ ⎧%.6ls%.3ls⎫ ⎧%.6ls%.3ls⎫ ⎧%.6ls%.3ls⎫ ⎪🮊▎⎪ 🯴🯵\n",
|
|
|
|
ncplane_printf(n, " ⎧%.6ls%.3ls⎫ ⎧%.6ls%.3ls⎫ ⎧%.6ls%.3ls⎫ ⎧%.6ls%.3ls⎫ ⎪🮊▎⎪ 🯴🯵\n",
|
|
|
|
NCBOXLIGHTW, NCBOXLIGHTW + 4,
|
|
|
|
NCBOXLIGHTW, NCBOXLIGHTW + 4,
|
|
|
|
NCBOXHEAVYW, NCBOXHEAVYW + 4,
|
|
|
|
NCBOXHEAVYW, NCBOXHEAVYW + 4,
|
|
|
|
NCBOXROUNDW, NCBOXROUNDW + 4,
|
|
|
|
NCBOXROUNDW, NCBOXROUNDW + 4,
|
|
|
|
NCBOXDOUBLEW, NCBOXDOUBLEW + 4);
|
|
|
|
NCBOXDOUBLEW, NCBOXDOUBLEW + 4);
|
|
|
|
fprintf(fp, " ⎩%.6ls%.3ls⎭ ⎩%.6ls%.3ls⎭ ⎩%.6ls%.3ls⎭ ⎩%.6ls%.3ls⎭ ⎪🮉▍⎪ 🯶🯷\n",
|
|
|
|
ncplane_printf(n, " ⎩%.6ls%.3ls⎭ ⎩%.6ls%.3ls⎭ ⎩%.6ls%.3ls⎭ ⎩%.6ls%.3ls⎭ ⎪🮉▍⎪ 🯶🯷\n",
|
|
|
|
NCBOXLIGHTW + 2, NCBOXLIGHTW + 5,
|
|
|
|
NCBOXLIGHTW + 2, NCBOXLIGHTW + 5,
|
|
|
|
NCBOXHEAVYW + 2, NCBOXHEAVYW + 5,
|
|
|
|
NCBOXHEAVYW + 2, NCBOXHEAVYW + 5,
|
|
|
|
NCBOXROUNDW + 2, NCBOXROUNDW + 5,
|
|
|
|
NCBOXROUNDW + 2, NCBOXROUNDW + 5,
|
|
|
|
NCBOXDOUBLEW + 2, NCBOXDOUBLEW + 5);
|
|
|
|
NCBOXDOUBLEW + 2, NCBOXDOUBLEW + 5);
|
|
|
|
fprintf(fp, " ⎡%.192ls⎤ ⎨▐▌⎬ 🯸🯹\n", NCBRAILLEEGCS);
|
|
|
|
ncplane_printf(n, " ⎡%.192ls⎤ ⎨▐▌⎬ 🯸🯹\n", NCBRAILLEEGCS);
|
|
|
|
fprintf(fp, " ⎢%.192ls⎥ ⎪🮈▋⎪\n", NCBRAILLEEGCS + 64);
|
|
|
|
ncplane_printf(n, " ⎢%.192ls⎥ ⎪🮈▋⎪\n", NCBRAILLEEGCS + 64);
|
|
|
|
fprintf(fp, " ⎢%.192ls⎥ ⎪🮇▊⎪\n", NCBRAILLEEGCS + 128);
|
|
|
|
ncplane_printf(n, " ⎢%.192ls⎥ ⎪🮇▊⎪\n", NCBRAILLEEGCS + 128);
|
|
|
|
fprintf(fp, " ⎣%.192ls⎦ ⎪▕▉⎪\n", NCBRAILLEEGCS + 192);
|
|
|
|
ncplane_printf(n, " ⎣%.192ls⎦ ⎪▕▉⎪\n", NCBRAILLEEGCS + 192);
|
|
|
|
fprintf(fp, " ⎛%ls⎞ ▔🭶🭷🭸🭹🭺🭻▁ 🭁 🭂 🭃 🭄 🭅 🭆 🭑 🭐 🭏 🭎 🭍 🭌 🭆🭑 🭄🭏 🭅🭐 🭃🭎 🭂🭍 🭁🭌 🭨🭪 ⎩ █⎭\n",
|
|
|
|
ncplane_printf(n, " ⎛%ls⎞ ▔🭶🭷🭸🭹🭺🭻▁ 🭁 🭂 🭃 🭄 🭅 🭆 🭑 🭐 🭏 🭎 🭍 🭌 🭆🭑 🭄🭏 🭅🭐 🭃🭎 🭂🭍 🭁🭌 🭨🭪 ⎩ █⎭\n",
|
|
|
|
NCEIGHTHSBOTTOM);
|
|
|
|
NCEIGHTHSBOTTOM);
|
|
|
|
fprintf(fp, " ⎝%ls⎠ ▏🭰🭱🭲🭳🭴🭵▕ 🭒 🭓 🭔 🭕 🭖 🭧 🭜 🭟 🭠 🭡 🭞 🭝 🭧🭜 🭕🭠 🭖🭡 🭔🭟 🭓🭞 🭒🭝 🭪🭨 \n",
|
|
|
|
ncplane_printf(n, " ⎝%ls⎠ ▏🭰🭱🭲🭳🭴🭵▕ 🭒 🭓 🭔 🭕 🭖 🭧 🭜 🭟 🭠 🭡 🭞 🭝 🭧🭜 🭕🭠 🭖🭡 🭔🭟 🭓🭞 🭒🭝 🭪🭨 \n",
|
|
|
|
NCEIGHTSTOP);
|
|
|
|
NCEIGHTSTOP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
static void
|
|
|
|
tinfo_debug_bitmaps(const tinfo* ti, FILE* fp, const char* indent){
|
|
|
|
tinfo_debug_bitmaps(struct ncplane* n, const tinfo* ti, const char* indent){
|
|
|
|
if(!ti->pixel_draw){
|
|
|
|
if(!ti->pixel_draw){
|
|
|
|
fprintf(fp, "%sdidn't detect bitmap graphics support\n", indent);
|
|
|
|
ncplane_printf(n, "%sdidn't detect bitmap graphics support\n", indent);
|
|
|
|
}else if(ti->sixel_maxy){
|
|
|
|
}else if(ti->sixel_maxy){
|
|
|
|
fprintf(fp, "%smax sixel size: %dx%d colorregs: %u\n",
|
|
|
|
ncplane_printf(n, "%smax sixel size: %dx%d colorregs: %u\n",
|
|
|
|
indent, ti->sixel_maxy, ti->sixel_maxx, ti->color_registers);
|
|
|
|
indent, ti->sixel_maxy, ti->sixel_maxx, ti->color_registers);
|
|
|
|
}else if(ti->color_registers){
|
|
|
|
}else if(ti->color_registers){
|
|
|
|
fprintf(fp, "%ssixel colorregs: %u\n", indent, ti->color_registers);
|
|
|
|
ncplane_printf(n, "%ssixel colorregs: %u\n", indent, ti->color_registers);
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
fprintf(fp, "%srgba pixel graphics supported\n", indent);
|
|
|
|
ncplane_printf(n, "%srgba pixel graphics supported\n", indent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
static void
|
|
|
|
tinfo_debug_style(const tinfo* ti, FILE* fp, const char* name, int esc, int deesc){
|
|
|
|
tinfo_debug_style(struct ncplane* n, const char* name, int style){
|
|
|
|
const char* code = get_escape(ti, esc);
|
|
|
|
ncplane_set_styles(n, style);
|
|
|
|
if(code){
|
|
|
|
ncplane_putstr(n, name);
|
|
|
|
term_emit(code, fp, false);
|
|
|
|
ncplane_set_styles(n, NCSTYLE_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(fp, "%s", name);
|
|
|
|
|
|
|
|
if(code){
|
|
|
|
|
|
|
|
code = get_escape(ti, deesc);
|
|
|
|
|
|
|
|
term_emit(code, fp, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline wchar_t
|
|
|
|
static inline wchar_t
|
|
|
@ -100,8 +77,8 @@ capyn(const tinfo* ti, const char* cap){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
static void
|
|
|
|
tinfo_debug_caps(const tinfo* ti, FILE* debugfp, const char* indent){
|
|
|
|
tinfo_debug_caps(struct ncplane* n, const tinfo* ti, const char* indent){
|
|
|
|
fprintf(debugfp, "%srgb%lc ccc%lc af%lc ab%lc appsync%lc u7%lc cup%lc vpa%lc hpa%lc sgr%lc sgr0%lc op%lc fgop%lc bgop%lc\n",
|
|
|
|
ncplane_printf(n, "%srgb%lc ccc%lc af%lc ab%lc appsync%lc u7%lc cup%lc vpa%lc hpa%lc sgr%lc sgr0%lc op%lc fgop%lc bgop%lc\n",
|
|
|
|
indent,
|
|
|
|
indent,
|
|
|
|
capbool(ti, ti->caps.rgb),
|
|
|
|
capbool(ti, ti->caps.rgb),
|
|
|
|
capbool(ti, ti->caps.can_change_colors),
|
|
|
|
capbool(ti, ti->caps.can_change_colors),
|
|
|
@ -117,37 +94,28 @@ tinfo_debug_caps(const tinfo* ti, FILE* debugfp, const char* indent){
|
|
|
|
capyn(ti, get_escape(ti, ESCAPE_OP)),
|
|
|
|
capyn(ti, get_escape(ti, ESCAPE_OP)),
|
|
|
|
capyn(ti, get_escape(ti, ESCAPE_FGOP)),
|
|
|
|
capyn(ti, get_escape(ti, ESCAPE_FGOP)),
|
|
|
|
capyn(ti, get_escape(ti, ESCAPE_BGOP)));
|
|
|
|
capyn(ti, get_escape(ti, ESCAPE_BGOP)));
|
|
|
|
fprintf(debugfp, "%sbackground of 0x%06lx is %sconsidered transparent\n", indent, ti->bg_collides_default & 0xfffffful,
|
|
|
|
ncplane_printf(n, "%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 ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
static void
|
|
|
|
tinfo_debug_styles(const tinfo* ti, FILE* debugfp, const char* indent){
|
|
|
|
tinfo_debug_styles(struct ncplane* n, const char* indent){
|
|
|
|
fprintf(debugfp, "%s", indent);
|
|
|
|
ncplane_putstr(n, indent);
|
|
|
|
tinfo_debug_style(ti, debugfp, "bold", ESCAPE_BOLD, ESCAPE_SGR0);
|
|
|
|
tinfo_debug_style(n, "bold", NCSTYLE_BOLD);
|
|
|
|
fprintf(debugfp, " ");
|
|
|
|
ncplane_putchar(n, ' ');
|
|
|
|
tinfo_debug_style(ti, debugfp, "ital", ESCAPE_SITM, ESCAPE_RITM);
|
|
|
|
tinfo_debug_style(n, "ital", NCSTYLE_ITALIC);
|
|
|
|
fprintf(debugfp, " ");
|
|
|
|
ncplane_putchar(n, ' ');
|
|
|
|
tinfo_debug_style(ti, debugfp, "struck", ESCAPE_SMXX, ESCAPE_RMXX);
|
|
|
|
tinfo_debug_style(n, "struck", NCSTYLE_STRUCK);
|
|
|
|
fprintf(debugfp, " ");
|
|
|
|
ncplane_putchar(n, ' ');
|
|
|
|
tinfo_debug_style(ti, debugfp, "ucurl", ESCAPE_SMULX, ESCAPE_SMULNOX);
|
|
|
|
tinfo_debug_style(n, "ucurl", NCSTYLE_UNDERCURL);
|
|
|
|
fprintf(debugfp, " ");
|
|
|
|
ncplane_putchar(n, ' ');
|
|
|
|
tinfo_debug_style(ti, debugfp, "uline", ESCAPE_SMUL, ESCAPE_RMUL);
|
|
|
|
tinfo_debug_style(n, "uline", NCSTYLE_UNDERLINE);
|
|
|
|
fprintf(debugfp, "\n");
|
|
|
|
ncplane_putchar(n, '\n');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// we should probably change this up to use regular good ol'
|
|
|
|
// we should probably change this up to use regular good ol'
|
|
|
|
// notcurses_render() without the alternate screen, no?
|
|
|
|
// notcurses_render() without the alternate screen, no?
|
|
|
|
int main(void){
|
|
|
|
int main(void){
|
|
|
|
char* mbuf = NULL;
|
|
|
|
|
|
|
|
size_t len = 0;
|
|
|
|
|
|
|
|
FILE* mstream;
|
|
|
|
|
|
|
|
if((mstream = open_memstream(&mbuf, &len)) == NULL){
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(fprintf(mstream, "\n") != 1){
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
notcurses_options nopts = {
|
|
|
|
notcurses_options nopts = {
|
|
|
|
.flags = NCOPTION_NO_ALTERNATE_SCREEN,
|
|
|
|
.flags = NCOPTION_NO_ALTERNATE_SCREEN,
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -156,20 +124,17 @@ int main(void){
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const char indent[] = " ";
|
|
|
|
const char indent[] = " ";
|
|
|
|
tinfo_debug_caps(&nc->tcache, mstream, indent);
|
|
|
|
struct ncplane* stdn = notcurses_stdplane(nc);
|
|
|
|
tinfo_debug_styles(&nc->tcache, mstream, indent);
|
|
|
|
// FIXME want cursor wherever it was
|
|
|
|
tinfo_debug_bitmaps(&nc->tcache, mstream, indent);
|
|
|
|
// FIXME want scrolling on standard plane
|
|
|
|
unicodedumper(nc, mstream, &nc->tcache, indent);
|
|
|
|
tinfo_debug_caps(stdn, &nc->tcache, indent);
|
|
|
|
if(fclose(mstream)){
|
|
|
|
tinfo_debug_styles(stdn, indent);
|
|
|
|
notcurses_stop(nc);
|
|
|
|
tinfo_debug_bitmaps(stdn, &nc->tcache, indent);
|
|
|
|
fprintf(stderr, "Error closing memstream after %zuB\n", len);
|
|
|
|
unicodedumper(nc, stdn, &nc->tcache, indent);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
if(notcurses_render(nc)){
|
|
|
|
}
|
|
|
|
|
|
|
|
if(writen(fileno(stdout), mbuf, len) < 0){
|
|
|
|
|
|
|
|
notcurses_stop(nc);
|
|
|
|
notcurses_stop(nc);
|
|
|
|
fprintf(stderr, "Error writing %zuB memstream\n", len);
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(mbuf);
|
|
|
|
// FIXME want cursor wherever it ought be
|
|
|
|
return notcurses_stop(nc) ? EXIT_FAILURE : EXIT_SUCCESS;
|
|
|
|
return notcurses_stop(nc) ? EXIT_FAILURE : EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|