notcurses-demo: implement debug window #1013

pull/1087/head
nick black 4 years ago committed by Nick Black
parent 957d15410c
commit f9b4993b07

@ -93,23 +93,34 @@ debug_toggle(struct notcurses* nc){
if(fclose(mstream)){
return;
}
// FIXME base rows on actual lines of output
ncplane_options nopts = {
.y = 3,
.horiz = {
.align = NCALIGN_CENTER,
},
.rows = count_debug_lines(output, outputlen) + 2,
.cols = dimx,
.rows = count_debug_lines(output, outputlen) + 1,
.cols = dimx + 1, // so we don't break lines before the true boundary
.flags = NCPLANE_OPTION_HORALIGNED,
};
// FIXME create debug window
struct ncplane* n = ncplane_create(notcurses_stdplane(nc), &nopts);
if(n == NULL){
free(output);
return;
}
// FIXME fill in window
uint64_t channels = 0;
channels_set_fg_alpha(&channels, CELL_ALPHA_TRANSPARENT);
channels_set_bg_rgb(&channels, 0xffffe5);
ncplane_set_base(n, " ", 0, channels);
ncplane_set_scrolling(n, true);
ncplane_set_fg_rgb(n, 0x0a0a0a);
ncplane_set_bg_rgb(n, 0xffffe5);
if(ncplane_puttext(n, 0, NCALIGN_CENTER, output, &outputlen) < 0){
free(output);
ncplane_destroy(n);
return;
}
ncplane_putstr_aligned(n, ncplane_dim_y(n) - 1, NCALIGN_CENTER, "Press Alt+d to hide this window");
free(output);
debug = n;
}

@ -4,7 +4,7 @@ void notcurses_debug(notcurses* nc, FILE* debugfp){
const ncplane* n = nc->top;
const ncplane* prev = NULL;
int planeidx = 0;
fprintf(debugfp, "*************************** notcurses debug state *****************************\n");
fprintf(debugfp, " ************************** notcurses debug state *****************************\n");
while(n){
fprintf(debugfp, "%04d off y: %3d x: %3d geom y: %3d x: %3d curs y: %3d x: %3d %p %.8s\n",
planeidx, n->absy, n->absx, n->leny, n->lenx, n->y, n->x, n, n->name);
@ -28,5 +28,5 @@ void notcurses_debug(notcurses* nc, FILE* debugfp){
if(nc->bottom != prev){
fprintf(stderr, " WARNING: expected ->bottom %p, got %p\n", prev, nc->bottom);
}
fprintf(debugfp, "*******************************************************************************\n");
fprintf(debugfp, " ******************************************************************************\n");
}

Loading…
Cancel
Save