mirror of
https://github.com/mintycube/st.git
synced 2024-10-22 14:05:49 +02:00
sixel: refactor the sixel display mode (#142)
This does not change the current behavior of SDM.
This commit is contained in:
parent
546dd288c0
commit
48c85cdcf5
48
st.c
48
st.c
@ -220,6 +220,9 @@ static void tsetattr(const int *, int);
|
||||
static void tsetchar(Rune, const Glyph *, int, int);
|
||||
static void tsetdirt(int, int);
|
||||
static void tsetscroll(int, int);
|
||||
#if SIXEL_PATCH
|
||||
static inline void tsetsixelattr(Line line, int x1, int x2);
|
||||
#endif // SIXEL_PATCH
|
||||
static void tswapscreen(void);
|
||||
static void tsetmode(int, int, const int *, int);
|
||||
static int twrite(const char *, int, int);
|
||||
@ -1149,6 +1152,15 @@ tsetdirtattr(int attr)
|
||||
}
|
||||
}
|
||||
|
||||
#if SIXEL_PATCH
|
||||
void
|
||||
tsetsixelattr(Line line, int x1, int x2)
|
||||
{
|
||||
for (; x1 <= x2; x1++)
|
||||
line[x1].mode |= ATTR_SIXEL;
|
||||
}
|
||||
#endif // SIXEL_PATCH
|
||||
|
||||
void
|
||||
tfulldirt(void)
|
||||
{
|
||||
@ -2592,7 +2604,7 @@ strhandle(void)
|
||||
};
|
||||
#if SIXEL_PATCH
|
||||
ImageList *im, *newimages, *next, *tail;
|
||||
int i, x, y, x1, y1, x2, y2, numimages;
|
||||
int i, x1, y1, x2, y2, numimages;
|
||||
int cx, cy;
|
||||
Line line;
|
||||
#if SCROLLBACK_PATCH || REFLOW_PATCH
|
||||
@ -2736,37 +2748,41 @@ strhandle(void)
|
||||
} else {
|
||||
term.images = newimages;
|
||||
}
|
||||
x2 = MIN(x2, term.col);
|
||||
x2 = MIN(x2, term.col) - 1;
|
||||
if (IS_SET(MODE_SIXEL_SDM)) {
|
||||
/* Sixel display mode: put the sixel in the upper left corner of
|
||||
* the screen, disable scrolling (the sixel will be truncated if
|
||||
* it is too long) and do not change the cursor position. */
|
||||
for (i = 0, im = newimages; im; im = next, i++) {
|
||||
next = im->next;
|
||||
#if SCROLLBACK_PATCH || REFLOW_PATCH
|
||||
scr = IS_SET(MODE_ALTSCREEN) ? 0 : term.scr;
|
||||
#endif // SCROLLBACK_PATCH
|
||||
if (IS_SET(MODE_SIXEL_SDM)) {
|
||||
if (i >= term.row) {
|
||||
delete_image(im);
|
||||
continue;
|
||||
}
|
||||
im->y = i + scr;
|
||||
line = term.line[i];
|
||||
} else {
|
||||
im->y = term.c.y + scr;
|
||||
line = term.line[term.c.y];
|
||||
}
|
||||
for (x = im->x; x < x2; x++) {
|
||||
line[x].mode |= ATTR_SIXEL;
|
||||
}
|
||||
tsetsixelattr(term.line[i], x1, x2);
|
||||
term.dirty[MIN(im->y, term.row-1)] = 1;
|
||||
if (!IS_SET(MODE_SIXEL_SDM) && i < numimages-1) {
|
||||
}
|
||||
} else {
|
||||
for (i = 0, im = newimages; im; im = next, i++) {
|
||||
next = im->next;
|
||||
#if SCROLLBACK_PATCH || REFLOW_PATCH
|
||||
scr = IS_SET(MODE_ALTSCREEN) ? 0 : term.scr;
|
||||
#endif // SCROLLBACK_PATCH
|
||||
im->y = term.c.y + scr;
|
||||
tsetsixelattr(term.line[term.c.y], x1, x2);
|
||||
term.dirty[MIN(im->y, term.row-1)] = 1;
|
||||
if (i < numimages-1) {
|
||||
im->next = NULL;
|
||||
tnewline(0);
|
||||
im->next = next;
|
||||
}
|
||||
}
|
||||
/* if mode 8452 is set, sixel scrolling leaves cursor to right of graphic */
|
||||
if (!IS_SET(MODE_SIXEL_SDM) && IS_SET(MODE_SIXEL_CUR_RT))
|
||||
if (IS_SET(MODE_SIXEL_CUR_RT))
|
||||
term.c.x = MIN(term.c.x + newimages->cols, term.col-1);
|
||||
}
|
||||
}
|
||||
#endif // SIXEL_PATCH
|
||||
#if SYNC_PATCH
|
||||
/* https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-spec */
|
||||
|
Loading…
Reference in New Issue
Block a user