add new PoC caps-rendered #1430

pull/1442/head
nick black 3 years ago
parent 214ca464aa
commit f658629a1b
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -3403,7 +3403,12 @@ API void ncreader_destroy(struct ncreader* n, char** contents);
// Dump selected Notcurses state to the supplied 'debugfp'. Output is freeform,
// and subject to change. It includes geometry of all planes, from all piles.
API void notcurses_debug(struct notcurses* nc, FILE* debugfp)
API void notcurses_debug(const struct notcurses* nc, FILE* debugfp)
__attribute__ ((nonnull (1, 2)));
// Dump selected configuration capabilities to 'debugfp'. Output is freeform,
// and subject to change.
API void notcurses_debug_caps(const struct notcurses* nc, FILE* debugfp)
__attribute__ ((nonnull (1, 2)));
// replaced by ncvisual_media_defblitter(). this original version never returns

@ -1,5 +1,60 @@
#include "internal.h"
static inline char
capyn(const char* cap){
return cap ? 'y' : 'n';
}
static inline char
capbool(bool cap){
return cap ? 'y' : 'n';
}
static void
tinfo_debug_caps(const tinfo* ti, FILE* debugfp, int rows, int cols,
unsigned images, unsigned videos){
const char indent[] = " ";
fprintf(debugfp, "%sColors: %u rgb: %c ccc: %c setaf: %c setbf: %c\n",
indent, ti->colors, capbool(ti->RGBflag), capbool(ti->CCCflag), capyn(ti->setaf), capyn(ti->setab));
fprintf(debugfp, "%ssgr: %c sgr0: %c\n",
indent, capyn(ti->sgr), capyn(ti->sgr0));
fprintf(debugfp, "%sop: %c fgop: %c bgop: %c\n",
indent, capyn(ti->op), capyn(ti->fgop), capyn(ti->bgop));
fprintf(debugfp, "%srows: %u cols: %u rpix: %u cpix: %u (%dx%d)\n",
indent, rows, cols, ti->cellpixy, ti->cellpixx, rows * ti->cellpixy, cols * ti->cellpixx);
if(!ti->pixel_query_done){
fprintf(debugfp, "%sno bitmap graphics information yet\n", indent);
}else{
if(!ti->sixel_supported){
fprintf(debugfp, "%sdidn't detect bitmap graphics support\n", indent);
}else if(ti->sixel_maxy || ti->color_registers){
fprintf(debugfp, "%smax bitmap size: %dx%d colorregs: %u\n",
indent, ti->sixel_maxy, ti->sixel_maxx, ti->color_registers);
}else{
fprintf(debugfp, "%sRGBA pixel graphics supported\n", indent);
}
}
fprintf(debugfp, "%sUTF8: %c sextants: %c braille: %c images: %c videos: %c\n",
indent, capbool(ti->utf8), capbool(ti->sextants), capbool(ti->braille),
capbool(images), capbool(videos));
if(ti->bg_collides_default){
fprintf(debugfp, "%sbackground of 0x%06lx is considered transparent\n", indent, ti->bg_collides_default & 0xfffffful);
}else{
fprintf(debugfp, "%sbackground isn't interpreted as transparent\n", indent);
}
fprintf(debugfp, "%scup: %c vpa: %c hpa: %c\n",
indent, capyn(ti->cup), capyn(ti->vpa), capyn(ti->hpa));
}
void notcurses_debug_caps(const notcurses* nc, FILE* debugfp){
int rows, cols;
notcurses_stddim_yx_const(nc, &rows, &cols);
bool images, videos;
images = notcurses_canopen_images(nc);
videos = notcurses_canopen_videos(nc);
tinfo_debug_caps(&nc->tcache, debugfp, rows, cols, images, videos);
}
static void
ncpile_debug(const ncpile* p, FILE* debugfp){
fprintf(debugfp, " ************************* %16p pile ****************************\n", p);
@ -31,7 +86,7 @@ ncpile_debug(const ncpile* p, FILE* debugfp){
}
}
void notcurses_debug(notcurses* nc, FILE* debugfp){
void notcurses_debug(const notcurses* nc, FILE* debugfp){
const ncpile* p = ncplane_pile(nc->stdplane);
fprintf(debugfp, " -------------------------- notcurses debug state -----------------------------\n");
const ncpile* p0 = p;

@ -269,7 +269,6 @@ typedef struct tinfo {
char* cuf; // move N cells right
char* cud; // move N cells down
char* cuf1; // move 1 cell right
char* cub1; // move 1 cell left
char* home; // home cursor
char* civis; // hide cursor
char* cnorm; // restore cursor to default state
@ -288,8 +287,6 @@ typedef struct tinfo {
char* initc; // set a palette entry's RGB value
char* oc; // restore original colors
char* clearscr; // erase screen and home cursor
char* cleareol; // clear to end of line
char* clearbol; // clear to beginning of line
char* sc; // push the cursor location onto the stack
char* rc; // pop the cursor location off the stack
char* smkx; // enter keypad transmit mode (keypad_xmit)

@ -0,0 +1,15 @@
#include <stdlib.h>
#include <notcurses/notcurses.h>
int main(void){
notcurses_options nopts = {
.flags = NCOPTION_NO_ALTERNATE_SCREEN,
};
struct notcurses* nc = notcurses_init(&nopts, NULL);
if(nc == NULL){
return EXIT_FAILURE;
}
notcurses_check_pixel_support(nc);
notcurses_debug_caps(nc, stdout);
return notcurses_stop(nc) ? EXIT_FAILURE : EXIT_SUCCESS;
}
Loading…
Cancel
Save