demo: make debug plane 81 wide, with transparent last column

This commit is contained in:
nick black 2021-04-22 00:38:05 -04:00
parent f4aa419a31
commit c7d284a9af
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
3 changed files with 14 additions and 3 deletions

View File

@ -3675,7 +3675,7 @@ API void ncreader_destroy(struct ncreader* n, char** contents);
// Dump selected Notcurses state to the supplied 'debugfp'. Output is freeform, // Dump selected Notcurses state to the supplied 'debugfp'. Output is freeform,
// newline-delimited, and subject to change. It includes geometry of all // newline-delimited, and subject to change. It includes geometry of all
// planes, from all piles. No line has more than 79 columns' worth of output. // planes, from all piles. No line has more than 80 columns' worth of output.
API void notcurses_debug(const struct notcurses* nc, FILE* debugfp) API void notcurses_debug(const struct notcurses* nc, FILE* debugfp)
__attribute__ ((nonnull (1, 2))); __attribute__ ((nonnull (1, 2)));

View File

@ -101,8 +101,12 @@ debug_toggle(struct notcurses* nc){
.y = 3, .y = 3,
.x = NCALIGN_CENTER, .x = NCALIGN_CENTER,
.rows = count_debug_lines(output, outputlen) + 1, .rows = count_debug_lines(output, outputlen) + 1,
.cols = 80, // make it one column longer than the maximum debug output, so that a full
// line of output doesn't cause trigger a newline. we'll make the last
// column transparent.
.cols = 81,
.flags = NCPLANE_OPTION_HORALIGNED, .flags = NCPLANE_OPTION_HORALIGNED,
.name = "dbg",
}; };
struct ncplane* n = ncplane_create(notcurses_stdplane(nc), &nopts); struct ncplane* n = ncplane_create(notcurses_stdplane(nc), &nopts);
if(n == NULL){ if(n == NULL){
@ -121,6 +125,13 @@ debug_toggle(struct notcurses* nc){
ncplane_destroy(n); ncplane_destroy(n);
return; return;
} }
for(int y = 0 ; y < ncplane_dim_y(n) ; ++y){
nccell c = CELL_TRIVIAL_INITIALIZER;
nccell_set_fg_alpha(&c, CELL_ALPHA_TRANSPARENT);
nccell_set_bg_alpha(&c, CELL_ALPHA_TRANSPARENT);
ncplane_putc_yx(n, y, ncplane_dim_x(n) - 1, &c);
nccell_release(n, &c);
}
ncplane_putstr_aligned(n, ncplane_dim_y(n) - 1, NCALIGN_CENTER, "Press Alt+d to hide this window"); ncplane_putstr_aligned(n, ncplane_dim_y(n) - 1, NCALIGN_CENTER, "Press Alt+d to hide this window");
free(output); free(output);
debug = n; debug = n;

View File

@ -63,7 +63,7 @@ ncpile_debug(const ncpile* p, FILE* debugfp){
const ncplane* prev = NULL; const ncplane* prev = NULL;
int planeidx = 0; int planeidx = 0;
while(n){ while(n){
fprintf(debugfp, "%04d off y: %3d x: %3d geom y: %3d x: %3d curs y: %3d x: %3d %p %.7s\n", fprintf(debugfp, "%04d off y: %3d x: %3d geom y: %3d x: %3d curs y: %3d x: %3d %p %.4s\n",
planeidx, n->absy, n->absx, n->leny, n->lenx, n->y, n->x, n, n->name); planeidx, n->absy, n->absx, n->leny, n->lenx, n->y, n->x, n, n->name);
if(n->boundto || n->bnext || n->bprev || n->blist){ if(n->boundto || n->bnext || n->bprev || n->blist){
fprintf(debugfp, " bound %p ← %p → %p binds %p\n", fprintf(debugfp, " bound %p ← %p → %p binds %p\n",