From 886255e941d3558ca69a5338e4e407465dc45f89 Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 31 Jul 2020 15:26:45 -0400 Subject: [PATCH] mojibake: clean up topmost line of display #842 --- src/demo/demo.c | 1 + src/demo/mojibake.c | 17 +++++++++++------ src/lib/notcurses.c | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/demo/demo.c b/src/demo/demo.c index b006fe59e..afaf6aafd 100644 --- a/src/demo/demo.c +++ b/src/demo/demo.c @@ -186,6 +186,7 @@ ext_demos(struct notcurses* nc, const char* spec, bool ignore_failures){ if(ret && !ignore_failures){ break; } + notcurses_refresh(nc, NULL, NULL); } return results; } diff --git a/src/demo/mojibake.c b/src/demo/mojibake.c index df345aa7a..1034e417e 100644 --- a/src/demo/mojibake.c +++ b/src/demo/mojibake.c @@ -3699,18 +3699,23 @@ int mojibake_demo(struct notcurses* nc){ do{ unsigned u = topmost; do{ - int y, x, leny; + int y, x, leny, lenx; ncplane_yx(planes[u], &y, &x); if(y >= dimy){ break; } - if(ncplane_move_yx(planes[u], y - 1, x)){ + ncplane_dim_yx(planes[u], &leny, &lenx); + if(y == 1){ + if(leny > 1){ + if(ncplane_resize(planes[u], 1, 0, leny - 1, lenx, -1, 0, leny - 1, lenx)){ + goto err; + } + }else{ + ++topmost; + } + }else if(ncplane_move_yx(planes[u], y - 1, x)){ goto err; } - ncplane_dim_yx(planes[u], &leny, NULL); - if(leny + y + 1 == 0){ - ++topmost; - } if(leny + y + 1 == dimy - 1){ if(u + 1 < sizeof(planes) / sizeof(*planes)){ if(ncplane_move_yx(planes[u + 1], dimy - 1, x)){ diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 674fbc012..3c603d6d7 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -490,8 +490,8 @@ int ncplane_resize_internal(ncplane* n, int keepy, int keepx, int keepleny, n->nc->stats.fbbytes -= sizeof(*preserved) * (rows * cols); n->nc->stats.fbbytes += fbsize; n->fb = fb; - n->absy = n->absy + keepy - yoff; - n->absx = n->absx + keepx - xoff; + n->absy += keepy + yoff; + n->absx += keepx + xoff; // if we're keeping nothing, dump the old egcspool. otherwise, we go ahead // and keep it. perhaps we ought compact it? if(keptarea == 0){ // keep nothing, resize/move only