From 8e96c2d78e07a15e042d724ae94dee93c1691340 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 30 Nov 2019 23:30:46 -0500 Subject: [PATCH] ncplane backgrounds: render and use i nsliding-demo #69 --- src/demo/sliding.c | 7 ++++++- src/lib/notcurses.c | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/demo/sliding.c b/src/demo/sliding.c index b97052fc7..58575ef95 100644 --- a/src/demo/sliding.c +++ b/src/demo/sliding.c @@ -85,7 +85,8 @@ fill_chunk(struct ncplane* n, int idx){ if(ncplane_cursor_move_yx(n, (maxy - 1) / 2, (maxx - 3) / 2)){ return -1; } - ncplane_fg_rgb8(n, 224, 224, 224); + ncplane_fg_rgb8(n, 255 - r, 255 - g, 255 - b); + ncplane_bg_rgb8(n, r, g, b); if(ncplane_putstr(n, buf) <= 0){ return -1; } @@ -96,6 +97,10 @@ fill_chunk(struct ncplane* n, int idx){ cell_release(n, &lr); cell_release(n, &hl); cell_release(n, &vl); + cell bg = CELL_TRIVIAL_INITIALIZER; + cell_set_bg(&bg, r, g, b); + ncplane_set_background(n, &bg); + cell_release(n, &bg); return 0; } diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index a1d6bd7ba..2446f8440 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -963,7 +963,11 @@ visible_cell(const notcurses* nc, int y, int x, const ncplane** retp){ if(poffy < p->leny && poffy >= 0){ if(poffx < p->lenx && poffx >= 0){ *retp = p; - return &p->fb[fbcellidx(p, poffy, poffx)]; + const cell* vis = &p->fb[fbcellidx(p, poffy, poffx)]; + if(vis->gcluster == 0){ + vis = &p->background; + } + return vis; } } p = p->z;