From 0a4b46a804f655df0716d5b903d86925c5655bb4 Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 18 Apr 2021 15:48:04 -0400 Subject: [PATCH] account for margins in sixel_state() #1561 --- src/lib/internal.h | 16 +++++++++------- src/lib/kitty.c | 2 +- src/lib/terminfo.c | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/lib/internal.h b/src/lib/internal.h index 803895e25..49cce271b 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -910,16 +910,17 @@ plane_debug(const ncplane* n, bool details){ } } +// cell coordinates *within the sprixel*, not absolute +int sprite_wipe(const notcurses* nc, sprixel* s, int y, int x); +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 sprite_kitty_cell_wipe(const notcurses* nc, sprixel* s, int y, int x); +int kitty_wipe(const notcurses* nc, sprixel* s, int y, int x); -// cell coordinates *within the sprixel*, not absolute -int sprite_wipe(const notcurses* nc, sprixel* s, int y, int x); -int sixel_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell); void sprixel_free(sprixel* s); void sprixel_hide(sprixel* s); + int sprite_draw(const notcurses* n, const ncpile *p, sprixel* s, FILE* out); int kitty_draw(const notcurses* n, const ncpile *p, sprixel* s, FILE* out); int sixel_draw(const notcurses* n, const ncpile *p, sprixel* s, FILE* out); @@ -988,9 +989,10 @@ scrub_tam_boundaries(sprixcell_e* tam, int leny, int lenx, int cdimy, int cdimx) // get the TAM entry for these (absolute) coordinates static inline sprixcell_e -sprixel_state(sprixel* s, int y, int x){ - int localy = y - s->n->absy; - int localx = x - s->n->absx; +sprixel_state(const sprixel* s, int y, int x){ + const ncplane* stdn = notcurses_stdplane_const(ncplane_notcurses_const(s->n)); + int localy = y - (s->n->absy - stdn->absy); + int localx = x - (s->n->absx - stdn->absx); assert(localy >= 0); assert(localy < s->dimy); assert(localx >= 0); diff --git a/src/lib/kitty.c b/src/lib/kitty.c index 3a094244f..8f8bd61bf 100644 --- a/src/lib/kitty.c +++ b/src/lib/kitty.c @@ -153,7 +153,7 @@ kitty_null(char* triplet, int skip, int max, int pleft){ } #define RGBA_MAXLEN 768 // 768 base64-encoded pixels in 4096 bytes -int sprite_kitty_cell_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell){ +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); return 0; // already annihilated, needn't draw glyph in kitty diff --git a/src/lib/terminfo.c b/src/lib/terminfo.c index 5c681217c..481a96632 100644 --- a/src/lib/terminfo.c +++ b/src/lib/terminfo.c @@ -61,7 +61,7 @@ apply_term_heuristics(tinfo* ti, const char* termname){ ti->quadrants = true; ti->pixel_query_done = true; ti->bitmap_supported = true; - ti->pixel_cell_wipe = sprite_kitty_cell_wipe; + ti->pixel_cell_wipe = kitty_wipe; ti->pixel_destroy = kitty_delete; ti->pixel_init = kitty_init; ti->pixel_draw = kitty_draw;