diff --git a/src/lib/internal.h b/src/lib/internal.h index 5c1d0957c..fa24b753f 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h @@ -321,7 +321,7 @@ 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); - int (*pixel_clear_all)(const struct notcurses* nc); + int (*pixel_init)(const struct notcurses* nc); bool pixel_query_done; // have we yet performed pixel query? bool sextants; // do we have (good, vetted) Unicode 13 sextant support? bool braille; // do we have Braille support? (linux console does not) @@ -730,9 +730,10 @@ sprixel* sprixel_create(ncplane* n, const char* s, int bytes, int placey, int pl int parse_start); API int sprite_wipe_cell(const notcurses* nc, sprixel* s, int y, int x); int sprite_kitty_annihilate(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s); -int sprite_kitty_clear_all(const notcurses* nc); +int sprite_kitty_init(const notcurses* nc); +int sprite_sixel_init(const notcurses* nc); int sprite_sixel_annihilate(const notcurses* nc, const ncpile* p, FILE* out, sprixel* s); -int sprite_clear_all(const notcurses* nc); +int sprite_init(const notcurses* nc); static inline void pool_release(egcpool* pool, nccell* c){ diff --git a/src/lib/kitty.c b/src/lib/kitty.c index 541776775..8ae6f9823 100644 --- a/src/lib/kitty.c +++ b/src/lib/kitty.c @@ -287,6 +287,6 @@ int kitty_blit(ncplane* nc, int linesize, const void* data, int begy, int begx, return r; } -int sprite_kitty_clear_all(const notcurses* nc){ +int sprite_kitty_init(const notcurses* nc){ return tty_emit("\e_Ga=d\e\\", nc->ttyfd); } diff --git a/src/lib/sixel.c b/src/lib/sixel.c index a8fcae4ea..ded05edf3 100644 --- a/src/lib/sixel.c +++ b/src/lib/sixel.c @@ -416,12 +416,7 @@ write_rle(int* printed, int color, FILE* fp, int seenrle, unsigned char crle){ // Emit the sprixel in its entirety, plus enable and disable pixel mode. static int write_sixel_data(FILE* fp, int lenx, sixeltable* stab, int* parse_start){ - // \e[?80: DECSDM "sixel scrolling" mode (put output at cursor location) - // \x90: 8-bit "device control sequence", lowercase q (start sixel) - // doesn't seem to work with at least xterm; we instead use '\ePq' - // FIXME i think we can print DESDM on the first one, and never again - *parse_start += fprintf(fp, "\e[?80h\ePq"); - + *parse_start = fprintf(fp, "\ePq"); // Set Raster Attributes - pan/pad=1 (pixel aspect ratio), Ph=lenx, Pv=leny // using Ph/Pv causes a background to be drawn using color register 0 for all // unspecified pixels, which we do not want. @@ -555,3 +550,10 @@ int sixel_blit(ncplane* nc, int linesize, const void* data, int begy, int begx, free(stable.table); return r; } + +int sprite_sixel_init(const notcurses* nc){ + // \e[?8452: DECSDM private "sixel scrolling" mode keeps the sixel from + // scrolling, but puts it at the current cursor location (as opposed to + // the upper left corner of the screen). + return tty_emit("\e[?8452h", nc->ttyfd); +} diff --git a/src/lib/sprite.c b/src/lib/sprite.c index 19d61dde0..cc39d02be 100644 --- a/src/lib/sprite.c +++ b/src/lib/sprite.c @@ -75,9 +75,9 @@ int sprite_wipe_cell(const notcurses* nc, sprixel* s, int ycell, int xcell){ return r; } -int sprite_clear_all(const notcurses* nc){ - if(!nc->tcache.pixel_clear_all){ +int sprite_init(const notcurses* nc){ + if(!nc->tcache.pixel_init){ return 0; } - return nc->tcache.pixel_clear_all(nc); + return nc->tcache.pixel_init(nc); }