[kitty] pass q=0 with final chunk

pull/1418/head
nick black 4 years ago committed by Nick Black
parent 9d7689b684
commit cd48c78eb2

@ -62,7 +62,8 @@ base64_rgba3(const uint32_t* pixels, size_t pcount, char* b64){
// pixel is 4B raw (32 bits). each chunk of three pixels is then 12 bytes, or // pixel is 4B raw (32 bits). each chunk of three pixels is then 12 bytes, or
// 16 base64-encoded bytes. 4096 / 16 == 256 3-pixel groups, or 768 pixels. // 16 base64-encoded bytes. 4096 / 16 == 256 3-pixel groups, or 768 pixels.
static int static int
write_kitty_data(FILE* fp, int linesize, int leny, int lenx, const uint32_t* data){ write_kitty_data(FILE* fp, int linesize, int leny, int lenx,
const uint32_t* data, int sprixelid){
#define KITTY_MAXLEN 4096 // 4096B maximum payload #define KITTY_MAXLEN 4096 // 4096B maximum payload
if(linesize % sizeof(*data)){ if(linesize % sizeof(*data)){
return -1; return -1;
@ -78,12 +79,9 @@ write_kitty_data(FILE* fp, int linesize, int leny, int lenx, const uint32_t* dat
//fprintf(stderr, "total: %d chunks = %d, s=%d,v=%d\n", total, chunks, lenx, leny); //fprintf(stderr, "total: %d chunks = %d, s=%d,v=%d\n", total, chunks, lenx, leny);
while(chunks--){ while(chunks--){
if(totalout == 0){ if(totalout == 0){
// FIXME need to send image id from notcurses struct fprintf(fp, "\e_Gf=32,s=%d,v=%d,i=%d,a=T%s;", lenx, leny, sprixelid, chunks > 1 ? ",m=1" : "");
static int horror = 1;
fprintf(fp, "\e_Gf=32,s=%d,v=%d,i=%d,a=T%s;", lenx, leny, horror, chunks > 1 ? ",m=1" : "");
++horror;
}else{ }else{
fprintf(fp, "\e_Gm=%d;", chunks ? 1 : 0); fprintf(fp, "\e_G%sm=%d;", chunks ? "" : "q=1,", chunks ? 1 : 0);
} }
if((targetout += RGBA_MAXLEN) > total){ if((targetout += RGBA_MAXLEN) > total){
targetout = total; targetout = total;
@ -131,12 +129,12 @@ int kitty_blit_inner(ncplane* nc, int linesize, int leny, int lenx,
if(fp == NULL){ if(fp == NULL){
return -1; return -1;
} }
if(write_kitty_data(fp, linesize, leny, lenx, data)){ if(write_kitty_data(fp, linesize, leny, lenx, data, bargs->pixel.sprixelid)){
fclose(fp); fclose(fp);
free(buf); free(buf);
return -1; return -1;
} }
if(plane_blit_sixel(nc, buf, size, rows, cols) < 0){ if(plane_blit_sixel(nc, buf, size, rows, cols, bargs->pixel.sprixelid) < 0){
free(buf); free(buf);
return -1; return -1;
} }

Loading…
Cancel
Save