add sprixel_rebuild interface, kitty + sixel skeletons #1440

pull/1604/head
nick black 3 years ago committed by Nick Black
parent 7c69a17752
commit 3e0783593d

@ -450,6 +450,8 @@ typedef struct tinfo {
// means leaving out the pixels (and likely resizes the string). for kitty,
// this means dialing down their alpha to 0 (in equivalent space).
int (*pixel_cell_wipe)(const struct notcurses* nc, sprixel* s, int y, int x);
// perform the inverse of pixel_cell_wipe, restoring an annihilated sprixcell.
int (*pixel_rebuild)(const struct notcurses* nc, sprixel* s, int y, int x);
int (*pixel_remove)(int id, FILE* out); // kitty only, issue actual delete command
int (*pixel_init)(int fd); // called when support is detected
int (*pixel_draw)(const struct notcurses* n, const struct ncpile* p, sprixel* s, FILE* out);
@ -922,7 +924,9 @@ int sixel_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell);
// nulls out a cell from a kitty bitmap via changing the alpha value
// throughout to 0. the same trick doesn't work on sixel, but there we
// can just print directly over the bitmap.
int kitty_wipe(const notcurses* nc, sprixel* s, int y, int x);
int kitty_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell);
int sixel_rebuild(const notcurses* nc, sprixel* s, int ycell, int xcell);
int kitty_rebuild(const notcurses* nc, sprixel* s, int ycell, int xcell);
void sprixel_free(sprixel* s);
void sprixel_hide(sprixel* s);
@ -960,6 +964,11 @@ sprite_destroy(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s){
return nc->tcache.pixel_destroy(nc, p, out, s);
}
static inline int
sprite_rebuild(const notcurses* nc, sprixel* s, int ycell, int xcell){
return nc->tcache.pixel_rebuild(nc, s, ycell, xcell);
}
static inline void
clamp_to_sixelmax(const tinfo* t, int* y, int* x){
if(t->sixel_maxy && *y > t->sixel_maxy){

@ -153,6 +153,14 @@ kitty_null(char* triplet, int skip, int max, int pleft){
}
#define RGBA_MAXLEN 768 // 768 base64-encoded pixels in 4096 bytes
int kitty_rebuild(const notcurses* nc, sprixel* s, int ycell, int xcell){
(void)nc;
(void)s;
(void)ycell;
(void)xcell;
return 0;
}
int kitty_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell){
if(s->n->tacache[s->dimx * ycell + xcell] == SPRIXCELL_ANNIHILATED){
//fprintf(stderr, "CACHED WIPE %d %d/%d\n", s->id, ycell, xcell);

@ -178,8 +178,7 @@ paint_sprixel(ncplane* p, struct crender* rvec, int starty, int startx,
crender->sprixel = s;
}
if(sprixel_state(s, absy, absx) == SPRIXCELL_ANNIHILATED){
// FIXME rebuild!
fprintf(stderr, "annihilation UNDONE at %d/%d\n", y, x);
sprite_rebuild(nc, s, y, x);
}
}
}

@ -746,6 +746,14 @@ int sixel_init(int fd){
return tty_emit("\e[?80;8452h", fd);
}
int sixel_rebuild(const notcurses* nc, sprixel* s, int ycell, int xcell){
(void)nc;
(void)s;
(void)ycell;
(void)xcell;
return 0;
}
// we return -1 because we're not doing a proper wipe -- that's not possible
// using sixel. we just mark it as partially transparent, so that if it's
// redrawn, it's redrawn using P2=1.

@ -15,6 +15,7 @@ setup_sixel_bitmaps(tinfo* ti){
ti->pixel_destroy = sixel_destroy;
ti->pixel_cell_wipe = sixel_wipe;
ti->pixel_shutdown = sixel_shutdown;
ti->pixel_rebuild = sixel_rebuild;
ti->sprixel_height_factor = 6;
}
@ -27,6 +28,7 @@ setup_kitty_bitmaps(tinfo* ti){
ti->pixel_draw = kitty_draw;
ti->pixel_shutdown = kitty_shutdown;
ti->sprixel_height_factor = 1;
ti->pixel_rebuild = kitty_rebuild;
set_pixel_blitter(kitty_blit);
}

Loading…
Cancel
Save