Skip to content

Commit

Permalink
add setup_kitty_animation #1439
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Jul 1, 2021
1 parent 3872da9 commit b688c1d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
8 changes: 8 additions & 0 deletions src/lib/kitty.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,11 @@ uint8_t* kitty_trans_auxvec(const tinfo* ti){
}
return a;
}

sprixel* kitty_recycle(ncplane* n){
sprixel* hides = n->sprite;
int dimy = hides->dimy;
int dimx = hides->dimx;
sprixel_hide(hides);
return sprixel_alloc(n, dimy, dimx);
}
8 changes: 0 additions & 8 deletions src/lib/sprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ void sprixel_free(sprixel* s){

sprixel* sprite_recycle(ncplane* n){
assert(n->sprite);
const notcurses* nc = ncplane_notcurses_const(n);
if(nc->tcache.pixel_shutdown == kitty_shutdown){
sprixel* hides = n->sprite;
int dimy = hides->dimy;
int dimx = hides->dimx;
sprixel_hide(hides);
return sprixel_alloc(n, dimy, dimx);
}
return n->sprite;
}

Expand Down
19 changes: 19 additions & 0 deletions src/lib/termdesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ setup_sixel_bitmaps(tinfo* ti, int fd, bool invert80){
ti->pixel_remove = NULL;
ti->pixel_destroy = sixel_destroy;
ti->pixel_wipe = sixel_wipe;
ti->pixel_recycle = NULL;
ti->pixel_shutdown = sixel_shutdown;
ti->pixel_rebuild = sixel_rebuild;
ti->pixel_trans_auxvec = sixel_trans_auxvec;
Expand All @@ -71,6 +72,24 @@ setup_kitty_bitmaps(tinfo* ti, int fd){
ti->pixel_move = kitty_move;
ti->pixel_shutdown = kitty_shutdown;
ti->sprixel_scale_height = 1;
ti->pixel_recycle = kitty_recycle;
ti->pixel_rebuild = kitty_rebuild;
ti->pixel_clear_all = kitty_clear_all;
ti->pixel_trans_auxvec = kitty_trans_auxvec;
set_pixel_blitter(kitty_blit);
sprite_init(ti, fd);
}

static inline void
setup_kitty_animation(tinfo* ti, int fd){
ti->pixel_wipe = kitty_wipe;
ti->pixel_destroy = kitty_destroy;
ti->pixel_remove = kitty_remove;
ti->pixel_draw = kitty_draw;
ti->pixel_move = kitty_move;
ti->pixel_recycle = NULL;
ti->pixel_shutdown = kitty_shutdown;
ti->sprixel_scale_height = 1;
ti->pixel_rebuild = kitty_rebuild;
ti->pixel_clear_all = kitty_clear_all;
ti->pixel_trans_auxvec = kitty_trans_auxvec;
Expand Down
1 change: 1 addition & 0 deletions src/lib/termdesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ typedef struct tinfo {
int (*pixel_move)(const struct ncpile* p, struct sprixel* s, FILE* out);
int (*pixel_destroy)(const struct notcurses* nc, const struct ncpile* p, FILE* out, struct sprixel* s);
int (*pixel_shutdown)(int fd); // called during context shutdown
struct sprixel* (*pixel_recycle)(struct ncplane* n);
int (*pixel_clear_all)(int fd); // called during startup, kitty only
uint8_t* (*pixel_trans_auxvec)(const struct tinfo* ti); // create tranparent auxvec
// sprixel parameters. there are several different sprixel protocols, of
Expand Down

0 comments on commit b688c1d

Please sign in to comment.