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:
parent
dd8675943d
commit
118e965d0c
6 changed files with 85 additions and 33 deletions
32
st.c
32
st.c
|
|
@ -2714,14 +2714,18 @@ strhandle(void)
|
|||
y1 = newimages->y;
|
||||
x2 = x1 + newimages->cols;
|
||||
y2 = y1 + numimages;
|
||||
for (tail = NULL, im = term.images; im; im = next) {
|
||||
next = im->next;
|
||||
if (im->x >= x1 && im->x + im->cols <= x2 &&
|
||||
im->y >= y1 && im->y <= y2) {
|
||||
delete_image(im);
|
||||
continue;
|
||||
if (newimages->transparent) {
|
||||
for (tail = term.images; tail && tail->next; tail = tail->next);
|
||||
} else {
|
||||
for (tail = NULL, im = term.images; im; im = next) {
|
||||
next = im->next;
|
||||
if (im->x >= x1 && im->x + im->cols <= x2 &&
|
||||
im->y >= y1 && im->y <= y2) {
|
||||
delete_image(im);
|
||||
continue;
|
||||
}
|
||||
tail = im;
|
||||
}
|
||||
tail = im;
|
||||
}
|
||||
if (tail) {
|
||||
tail->next = newimages;
|
||||
|
|
@ -2747,8 +2751,7 @@ strhandle(void)
|
|||
line = term.line[term.c.y];
|
||||
}
|
||||
for (x = im->x; x < x2; x++) {
|
||||
line[x].u = ' ';
|
||||
line[x].mode = ATTR_SIXEL;
|
||||
line[x].mode |= ATTR_SIXEL;
|
||||
}
|
||||
term.dirty[MIN(im->y, term.row-1)] = 1;
|
||||
if (!IS_SET(MODE_SIXEL_SDM) && i < numimages-1) {
|
||||
|
|
@ -3097,7 +3100,7 @@ tcontrolcode(uchar ascii)
|
|||
void
|
||||
dcshandle(void)
|
||||
{
|
||||
int bgcolor;
|
||||
int bgcolor, transparent;
|
||||
unsigned char r, g, b, a = 255;
|
||||
|
||||
switch (csiescseq.mode[0]) {
|
||||
|
|
@ -3119,6 +3122,7 @@ dcshandle(void)
|
|||
break;
|
||||
#endif // SYNC_PATCH
|
||||
case 'q': /* DECSIXEL */
|
||||
transparent = (csiescseq.narg >= 2 && csiescseq.arg[1] == 1);
|
||||
if (IS_TRUECOL(term.c.attr.bg)) {
|
||||
r = term.c.attr.bg >> 16 & 255;
|
||||
g = term.c.attr.bg >> 8 & 255;
|
||||
|
|
@ -3129,7 +3133,7 @@ dcshandle(void)
|
|||
a = dc.col[defaultbg].pixel >> 24 & 255;
|
||||
}
|
||||
bgcolor = a << 24 | r << 16 | g << 8 | b;
|
||||
if (sixel_parser_init(&sixel_st, (255 << 24), bgcolor, 1, win.cw, win.ch) != 0)
|
||||
if (sixel_parser_init(&sixel_st, transparent, (255 << 24), bgcolor, 1, win.cw, win.ch) != 0)
|
||||
perror("sixel_parser_init() failed");
|
||||
term.mode |= MODE_SIXEL;
|
||||
break;
|
||||
|
|
@ -3632,10 +3636,8 @@ tresize(int col, int row)
|
|||
line = term.line[im->y];
|
||||
#endif // SCROLLBACK_PATCH
|
||||
x2 = MIN(im->x + im->cols, term.col);
|
||||
for (x = im->x; x < x2; x++) {
|
||||
line[x].u = ' ';
|
||||
line[x].mode = ATTR_SIXEL;
|
||||
}
|
||||
for (x = im->x; x < x2; x++)
|
||||
line[x].mode |= ATTR_SIXEL;
|
||||
}
|
||||
tswapscreen();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue