[pixel] add SPRIXEL_HIDE and sprixel_hide()

pull/1418/head
nick black 4 years ago committed by Nick Black
parent ccb02c61b3
commit 32d7af584d

@ -54,7 +54,11 @@ typedef struct sprixel {
char* glyph; // glyph; can be quite large
int id; // embedded into glusters field of nccell
struct ncplane* n; // associated ncplane, provides location and size
int invalidated;
enum {
SPRIXEL_NOCHANGE,
SPRIXEL_INVALIDATED,
SPRIXEL_HIDE,
} invalidated;
struct sprixel* next;
} sprixel;
@ -686,6 +690,7 @@ plane_debug(const ncplane* n, bool details){
}
void sprixel_free(sprixel* s);
void sprixel_hide(sprixel* s);
sprixel* sprixel_create(ncplane* n, const char* s, int bytes);
static inline void

@ -655,6 +655,9 @@ int ncplane_destroy(ncplane* ncp){
logerror(ncplane_notcurses(ncp), "Won't destroy standard plane\n");
return -1;
}
if(ncp->sprite){
sprixel_hide(ncp->sprite);
}
//notcurses_debug(ncplane_notcurses(ncp), stderr);
int ret = 0;
// dissolve our binding from behind (->bprev is either NULL, or its

@ -924,7 +924,7 @@ emit_bg_palindex(notcurses* nc, FILE* out, const nccell* srccell){
static int
rasterize_sprixels(notcurses* nc, FILE* out){
for(sprixel* s = nc->sprixelcache ; s ; s = s->next){
if(s->invalidated){
if(s->invalidated == SPRIXEL_INVALIDATED){
int y, x;
ncplane_yx(s->n, &y, &x);
if(goto_location(nc, out, y, x)){
@ -933,8 +933,10 @@ rasterize_sprixels(notcurses* nc, FILE* out){
if(ncfputs(s->glyph, out) < 0){
return -1;
}
s->invalidated = false;
s->invalidated = SPRIXEL_NOCHANGE;
nc->rstate.hardcursorpos = true;
}else if(s->invalidated == SPRIXEL_HIDE){
// FIXME delete it
}
}
return 0;

@ -7,6 +7,11 @@ void sprixel_free(sprixel* s){
}
}
void sprixel_hide(sprixel* s){
s->n->sprite = NULL;
s->invalidated = SPRIXEL_HIDE;
}
sprixel* sprixel_create(ncplane* n, const char* s, int bytes){
sprixel* ret = malloc(sizeof(sprixel));
if(ret){
@ -14,7 +19,7 @@ sprixel* sprixel_create(ncplane* n, const char* s, int bytes){
free(ret);
return NULL;
}
ret->invalidated = 1;
ret->invalidated = SPRIXEL_INVALIDATED;
ret->n = n;
if(ncplane_pile(n)){
notcurses* nc = ncplane_notcurses(n);

Loading…
Cancel
Save