sixel: add support for fully transparent bg (P2=1) (#132)

P2 selects how the terminal draws the background color.

P2                  Meaning
0 or 2 (default)    Pixel positions specified as 0 are set to the
                    current background color.
1                   Pixel positions specified as 0 remain at their
                    current color.

Both modes are now supported.

Ref. https://www.vt100.net/docs/vt3xx-gp/chapter14.html
This commit is contained in:
veltza 2024-04-17 19:04:27 +03:00 committed by GitHub
parent dd8675943d
commit 118e965d0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 85 additions and 33 deletions

View file

@ -81,7 +81,7 @@ treflow(int col, int row)
int oce, nce, bot, scr;
int ox = 0, oy = -term.histf, nx = 0, ny = -1, len;
int cy = -1; /* proxy for new y coordinate of cursor */
int buflen, nlines, del;
int buflen, nlines;
Line *buf, bufline, line;
#if SIXEL_PATCH
ImageList *im, *next;
@ -219,21 +219,14 @@ treflow(int col, int row)
}
}
/* expand images into new text cells or
* delete images if there is text behind them */
/* expand images into new text cells */
for (im = term.images; im; im = next) {
next = im->next;
if (im->x < col) {
line = TLINE(im->y);
x2 = MIN(im->x + im->cols, col);
for (del = 0, x = im->x; x < x2; x++) {
if ((del = line[x].mode & ATTR_SET))
break;
line[x].u = ' ';
line[x].mode = ATTR_SIXEL;
}
if (del)
delete_image(im);
for (x = im->x; x < x2; x++)
line[x].mode |= ATTR_SIXEL;
}
}
#endif // SIXEL_PATCH