From c7d284a9afe3f3d4f07545889fb36febc2771a3a Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 22 Apr 2021 00:38:05 -0400 Subject: [PATCH] demo: make debug plane 81 wide, with transparent last column --- include/notcurses/notcurses.h | 2 +- src/demo/hud.c | 13 ++++++++++++- src/lib/debug.c | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index fc6efd550..f543e6779 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -3675,7 +3675,7 @@ API void ncreader_destroy(struct ncreader* n, char** contents); // Dump selected Notcurses state to the supplied 'debugfp'. Output is freeform, // 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) __attribute__ ((nonnull (1, 2))); diff --git a/src/demo/hud.c b/src/demo/hud.c index db7f6a5ca..1e3e50f92 100644 --- a/src/demo/hud.c +++ b/src/demo/hud.c @@ -101,8 +101,12 @@ debug_toggle(struct notcurses* nc){ .y = 3, .x = NCALIGN_CENTER, .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, + .name = "dbg", }; struct ncplane* n = ncplane_create(notcurses_stdplane(nc), &nopts); if(n == NULL){ @@ -121,6 +125,13 @@ debug_toggle(struct notcurses* nc){ ncplane_destroy(n); 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"); free(output); debug = n; diff --git a/src/lib/debug.c b/src/lib/debug.c index 203b733f1..64c572036 100644 --- a/src/lib/debug.c +++ b/src/lib/debug.c @@ -63,7 +63,7 @@ ncpile_debug(const ncpile* p, FILE* debugfp){ const ncplane* prev = NULL; int planeidx = 0; 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); if(n->boundto || n->bnext || n->bprev || n->blist){ fprintf(debugfp, " bound %p ← %p → %p binds %p\n",