From 74744abc894d9239c188529e53b02031054ee8eb Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 18 Apr 2021 07:12:12 -0400 Subject: [PATCH] [sixel] don't damage on delete just because new sprixel is mixed #1553 --- src/lib/internal.h | 1 - src/lib/sixel.c | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/lib/internal.h b/src/lib/internal.h index 8f3f56867..91e1b3801 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -153,7 +153,6 @@ typedef struct sprixel { // both the plane and visual can die before the sprixel does. they are // responsible in such a case for NULLing out this link themselves. struct ncplane* n; // associated ncplane - struct ncvisual* ncv; // associated ncvisual sprixel_e invalidated;// sprixel invalidation state struct sprixel* next; int y, x; diff --git a/src/lib/sixel.c b/src/lib/sixel.c index 24e5dab6a..f21ac6396 100644 --- a/src/lib/sixel.c +++ b/src/lib/sixel.c @@ -516,7 +516,7 @@ int sixel_delete(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s){ for(int yy = s->movedfromy ; yy < s->movedfromy + s->dimy && yy < p->dimy ; ++yy){ for(int xx = s->movedfromx ; xx < s->movedfromx + s->dimx && xx < p->dimx ; ++xx){ struct crender *r = &p->crender[yy * p->dimx + xx]; - if(!r->sprixel || sprixel_state(r->sprixel, yy, xx) != SPRIXCELL_OPAQUE){ + if(!r->sprixel){ r->s.damaged = 1; } } @@ -527,7 +527,14 @@ int sixel_delete(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s){ int sixel_draw(const notcurses* n, const ncpile* p, sprixel* s, FILE* out){ (void)n; if(s->invalidated == SPRIXEL_MOVED){ - sixel_delete(n, p, out, s); + for(int yy = s->movedfromy ; yy < s->movedfromy + s->dimy && yy < p->dimy ; ++yy){ + for(int xx = s->movedfromx ; xx < s->movedfromx + s->dimx && xx < p->dimx ; ++xx){ + struct crender *r = &p->crender[yy * p->dimx + xx]; + if(!r->sprixel || sprixel_state(r->sprixel, yy, xx) != SPRIXCELL_OPAQUE){ + r->s.damaged = 1; + } + } + } s->invalidated = SPRIXEL_INVALIDATED; }else{ if(fwrite(s->glyph, s->glyphlen, 1, out) != 1){