From 1f254c47b24454f2a8bb5d91695d83525bf72acf Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 18 Jul 2021 16:34:58 -0400 Subject: [PATCH] implement child plane scrolling #1883 --- doc/man/man3/notcurses_plane.3.md | 5 +++-- src/lib/internal.h | 1 + src/lib/notcurses.c | 10 +++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/man/man3/notcurses_plane.3.md b/doc/man/man3/notcurses_plane.3.md index 1304c9f2a..70f98ce0a 100644 --- a/doc/man/man3/notcurses_plane.3.md +++ b/doc/man/man3/notcurses_plane.3.md @@ -383,8 +383,9 @@ other rows are moved up, the last row is cleared, and output begins at the beginning of the last row. This does not take place until output is generated (i.e. it is possible to fill a plane when scrolling is enabled). -By default, planes bound to a scrolling plane will scroll along with it. This -can be disabled with the **NCPLANE_OPTION_FIXED** flag. +By default, planes bound to a scrolling plane will scroll along with it, if +they intersect the plane. This can be disabled with the +**NCPLANE_OPTION_FIXED** flag. ## Bitmaps diff --git a/src/lib/internal.h b/src/lib/internal.h index e8f16a2a9..6201e6bcb 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -100,6 +100,7 @@ typedef struct ncplane { uint16_t stylemask; // same deal as in a cell int margin_b, margin_r;// bottom and right margins, stored for resize bool scrolling; // is scrolling enabled? always disabled by default + bool fixedbound; // are we fixed relative to the parent's scrolling? } ncplane; // current presentation state of the terminal. it is carried across render diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index d35c1d045..d30a7e646 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -417,6 +417,7 @@ ncplane* ncplane_new_internal(notcurses* nc, ncplane* n, return NULL; } p->scrolling = false; + p->fixedbound = nopts->flags & NCPLANE_OPTION_FIXED; if(nopts->flags & NCPLANE_OPTION_MARGINALIZED){ p->margin_b = nopts->margin_b; p->margin_r = nopts->margin_r; @@ -1529,7 +1530,8 @@ nccell_obliterate(ncplane* n, nccell* c){ nccell_init(c); } -// increment y by 1 and rotate the framebuffer up one line. x moves to 0. +// increment y by 1 and rotate the framebuffer up one line. x moves to 0. any +// non-fixed bound planes move up 1 line if they intersect the plane. void scroll_down(ncplane* n){ //fprintf(stderr, "pre-scroll: %d/%d %d/%d log: %d scrolling: %u\n", n->y, n->x, n->leny, n->lenx, n->logrow, n->scrolling); n->x = 0; @@ -1546,6 +1548,12 @@ void scroll_down(ncplane* n){ }else{ ++n->y; } + for(struct ncplane* c = n->blist ; c ; c = c->bnext){ + if(!c->fixedbound){ + // FIXME ought only be performed if we intersect the parent plane + ncplane_moverel(c, -1, 0); + } + } } int nccell_width(const ncplane* n __attribute__ ((unused)), const nccell* c){