diff --git a/src/lib/internal.h b/src/lib/internal.h index 8d2a5cc15..ad34a7ebc 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -437,6 +437,7 @@ typedef struct tinfo { // query the details of the implementation. pthread_mutex_t pixel_query; // only query for pixel support once int color_registers; // sixel color registers (post pixel_query_done) + int sprixel_height_factor; // sprixel height must be multiple of this int sixel_maxx, sixel_maxy; // sixel size maxima (post pixel_query_done) int sprixelnonce; // next sprixel id int (*pixel_destroy)(const struct notcurses* nc, const struct ncpile* p, FILE* out, sprixel* s); @@ -957,6 +958,9 @@ clamp_to_sixelmax(const tinfo* t, int* y, int* x){ if(t->sixel_maxy && *y > t->sixel_maxy){ *y = t->sixel_maxy; } + if(*y % t->sprixel_height_factor){ + *y -= (*y % t->sprixel_height_factor); + } if(t->sixel_maxx && *x > t->sixel_maxx){ *x = t->sixel_maxx; } diff --git a/src/lib/terminfo.c b/src/lib/terminfo.c index 481a96632..71ab2ef69 100644 --- a/src/lib/terminfo.c +++ b/src/lib/terminfo.c @@ -66,6 +66,7 @@ apply_term_heuristics(tinfo* ti, const char* termname){ ti->pixel_init = kitty_init; ti->pixel_draw = kitty_draw; ti->pixel_shutdown = kitty_shutdown; + ti->sprixel_height_factor = 1; set_pixel_blitter(kitty_blit); }else if(strstr(termname, "alacritty")){ ti->alacritty_sixel_hack = true; @@ -215,7 +216,9 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8) } } } - // if op is defined as ansi 39 + ansi 49, make the split definitions available + // if op is defined as ansi 39 + ansi 49, make the split definitions + // available. this ought be asserted by extension capability "ax", but + // no terminal i've found seems to do so. =[ if(ti->op && strcmp(ti->op, "\x1b[39;49m") == 0){ ti->fgop = "\x1b[39m"; ti->bgop = "\x1b[49m"; @@ -230,6 +233,7 @@ int interrogate_terminfo(tinfo* ti, int fd, const char* termname, unsigned utf8) } // FIXME need unit tests on this +// FIXME can read a character not intended for it static int read_xtsmgraphics_reply(int fd, int* val2){ char in; @@ -341,6 +345,7 @@ setup_sixel(tinfo* ti){ ti->pixel_destroy = sixel_delete; ti->pixel_cell_wipe = sixel_wipe; ti->pixel_shutdown = sixel_shutdown; + ti->sprixel_height_factor = 6; } // query for Sixel support diff --git a/src/lib/visual.c b/src/lib/visual.c index 8bd3594af..f0d157409 100644 --- a/src/lib/visual.c +++ b/src/lib/visual.c @@ -687,6 +687,7 @@ ncplane* ncvisual_render_pixels(notcurses* nc, ncvisual* ncv, const struct blits } if(flags & NCVISUAL_OPTION_VERALIGNED){ if(placey == NCALIGN_CENTER){ + // FIXME why are these calculations structurally different from HORALIGNED above? placey = ((ncplane_dim_y(n) * nc->tcache.cellpixy - disprows) / 2) / nc->tcache.cellpixy; }else if(placey == NCALIGN_BOTTOM){ placey = ncplane_dim_y(n) * nc->tcache.cellpixy - disprows / nc->tcache.cellpixy; diff --git a/src/tests/bitmap.cpp b/src/tests/bitmap.cpp index f0d1b6fde..e1d29f0e9 100644 --- a/src/tests/bitmap.cpp +++ b/src/tests/bitmap.cpp @@ -219,8 +219,8 @@ TEST_CASE("Bitmaps") { // verify that the sprixel's TAM is properly initialized SUBCASE("PixelTAMSetup") { - // first, assemble a visual equivalent to 81 cells - auto dimy = 9; + // first, assemble a visual equivalent to 54 cells + auto dimy = 6; auto dimx = 9; auto y = dimy * nc_->tcache.cellpixy; auto x = dimx * nc_->tcache.cellpixx;