on pile change, clear old sprixels #1875

pull/1867/head
nick black 3 years ago committed by Nick Black
parent 9d27bf1869
commit ed8c369d4e

@ -472,6 +472,12 @@ typedef struct notcurses {
// we keep a copy of the last rendered frame. this facilitates O(1)
// notcurses_at_yx() and O(1) damage detection (at the cost of some memory).
nccell* lastframe;// last rasterized framebuffer, NULL until first raster
// the last pile we rasterized. NULL until we've rasterized once. might
// be invalid due to the pile being destroyed; you are only allowed to
// evaluate it for equality to the pile being currently rasterized. when
// we switch piles, we need to clear all displayed sprixels, and
// invalidate the new pile's, pursuant to their display.
ncpile* last_pile;
egcpool pool; // egcpool for lastframe
int lfdimx; // dimensions of lastframe, unchanged by screen resize

@ -1036,6 +1036,7 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
if(ret == NULL){
return ret;
}
ret->last_pile = NULL;
ret->rstate.mstream = NULL;
ret->rstate.mstreamfp = NULL;
ret->loglevel = opts->loglevel;

@ -1119,12 +1119,16 @@ raster_and_write(notcurses* nc, ncpile* p, FILE* out){
return -1;
}
}
// if the last pile was different from this one, we need clear all old
// sprixels (and invalidate all those of the current pile -- FIXME).
if(nc->last_pile != p){
if(sprite_clear_all(&nc->tcache, out)){
return -1;
}
}
if(notcurses_rasterize_inner(nc, p, out, &useasu) < 0){
return -1;
}
int ret = 0;
sigset_t oldmask;
block_signals(&oldmask);
// if we loaded a BSU into the front, but don't actually want to use it,
// we start printing after the BSU.
size_t moffset = 0;
@ -1135,6 +1139,9 @@ raster_and_write(notcurses* nc, ncpile* p, FILE* out){
moffset = strlen(basu);
}
}
int ret = 0;
sigset_t oldmask;
block_signals(&oldmask);
if(blocking_write(fileno(nc->ttyfp), nc->rstate.mstream + moffset,
nc->rstate.mstrsize - moffset)){
ret = -1;
@ -1165,6 +1172,7 @@ notcurses_rasterize(notcurses* nc, ncpile* p, FILE* out){
if(cursory >= 0){
notcurses_cursor_enable(nc, cursory, cursorx);
}
nc->last_pile = p;
return ret;
}

Loading…
Cancel
Save