From 88f40df4aee38e5ec15475267a855fbc4eb395ce Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 11 Sep 2021 23:28:50 -0400 Subject: [PATCH] [plots] print current sample as summary #2152 --- include/notcurses/notcurses.h | 2 +- src/lib/plot.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index b80c0d342..045c8c0be 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -540,7 +540,7 @@ ncchannels_set_bg_default(uint64_t* channels){ // An nccell corresponds to a single character cell on some plane, which can be // occupied by a single grapheme cluster (some root spacing glyph, along with // possible combining characters, which might span multiple columns). At any -// cell, we can have a theoretically arbitrarily long UTF-8 string, a foreground +// cell, we can have a theoretically arbitrarily long UTF-8 EGC, a foreground // color, a background color, and an attribute set. Valid grapheme cluster // contents include: // diff --git a/src/lib/plot.c b/src/lib/plot.c index 7b6a23e51..0833d8c59 100644 --- a/src/lib/plot.c +++ b/src/lib/plot.c @@ -198,10 +198,12 @@ int redraw_pixelplot_##T(nc##X##plot* ncp){ \ } \ } \ if(ncp->plot.printsample){ \ - int lastslot = ncp->plot.slotstart ? ncp->plot.slotstart - 1 : ncp->plot.slotcount - 1; \ ncplane_set_styles(ncp->plot.ncp, ncp->plot.legendstyle); \ ncplane_set_channels(ncp->plot.ncp, ncp->plot.maxchannels); \ - ncplane_printf_aligned(ncp->plot.ncp, 0, NCALIGN_RIGHT, "%" PRIu64, (uint64_t)ncp->slots[lastslot]); \ + /* FIXME is this correct for double? */ \ + /* we use idx, and thus get an immediate count, changing as we load it. + * if you want a stable summary, print the previous slot */ \ + ncplane_printf_aligned(ncp->plot.ncp, 0, NCALIGN_RIGHT, "%" PRIu64, (uint64_t)ncp->slots[idx]); \ } \ ncplane_home(ncp->plot.ncp); \ struct ncvisual* ncv = ncvisual_from_rgba(pixels, dimy * states, dimx * scale * 4, dimx * scale); \ @@ -391,10 +393,9 @@ int redraw_plot_##T(nc##X##plot* ncp){ \ } \ } \ if(ncp->plot.printsample){ \ - int lastslot = ncp->plot.slotstart ? ncp->plot.slotstart - 1 : ncp->plot.slotcount - 1; \ ncplane_set_styles(ncp->plot.ncp, ncp->plot.legendstyle); \ ncplane_set_channels(ncp->plot.ncp, ncp->plot.maxchannels); \ - ncplane_printf_aligned(ncp->plot.ncp, 0, NCALIGN_RIGHT, "%" PRIu64, (uint64_t)ncp->slots[lastslot]); \ + ncplane_printf_aligned(ncp->plot.ncp, 0, NCALIGN_RIGHT, "%" PRIu64, (uint64_t)ncp->slots[idx]); \ } \ ncplane_home(ncp->plot.ncp); \ return 0; \