[sixel] use private scrolling #1433

This commit is contained in:
nick black 2021-03-22 03:08:10 -04:00 committed by Nick Black
parent 4cd3c9734c
commit 5ea47d856b
4 changed files with 16 additions and 13 deletions

View File

@ -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){

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}