Adding proposed scrollback changes for sixel graphics ref. #30

This commit is contained in:
bakkeby 2021-07-07 09:43:43 +02:00
parent fb8d6e378c
commit 426eca8f2e
5 changed files with 69 additions and 22 deletions

View File

@ -14,6 +14,10 @@ kscrolldown(const Arg* a)
selscroll(0, -n);
tfulldirt();
}
#if SIXEL_PATCH
scroll_images(-1*n);
#endif // SIXEL_PATCH
}
void
@ -28,4 +32,8 @@ kscrollup(const Arg* a)
selscroll(0, n);
tfulldirt();
}
#if SIXEL_PATCH
scroll_images(n);
#endif // SIXEL_PATCH
}

View File

@ -16,3 +16,27 @@ dcshandle(void)
break;
}
}
void
scroll_images(int n) {
ImageList *im;
int tmp;
/* maximum sixel distance in lines from current view before
* deallocation
* TODO: should be in config.h */
int max_sixel_distance = 10000;
for (im = term.images; im; im = im->next) {
im->y += n;
/* check if the current sixel has exceeded the maximum
* draw distance, and should therefore be deleted */
tmp = im->y;
if (tmp < 0) { tmp = tmp * -1; }
if (tmp > max_sixel_distance) {
fprintf(stderr, "im@0x%08x exceeded maximum distance\n");
im->should_delete = 1;
}
}
}

View File

@ -1 +1,2 @@
static void dcshandle(void);
static void scroll_images(int n);

53
st.c
View File

@ -1399,9 +1399,6 @@ tscrolldown(int orig, int n)
#endif // VIM_BROWSE_PATCH
int i;
Line temp;
#if SIXEL_PATCH
ImageList *im;
#endif // SIXEL_PATCH
LIMIT(n, 0, term.bot-orig+1);
@ -1424,12 +1421,7 @@ tscrolldown(int orig, int n)
}
#if SIXEL_PATCH
for (im = term.images; im; im = im->next) {
if (im->y < term.bot)
im->y += n;
if (im->y > term.bot)
im->should_delete = 1;
}
scroll_images(n);
#endif // SIXEL_PATCH
#if SCROLLBACK_PATCH
@ -1453,9 +1445,6 @@ tscrollup(int orig, int n)
#endif // VIM_BROWSE_PATCH
int i;
Line temp;
#if SIXEL_PATCH
ImageList *im;
#endif // SIXEL_PATCH
LIMIT(n, 0, term.bot-orig+1);
@ -1481,12 +1470,7 @@ tscrollup(int orig, int n)
}
#if SIXEL_PATCH
for (im = term.images; im; im = im->next) {
if (im->y+im->height/win.ch > term.top)
im->y -= n;
if (im->y+im->height/win.ch < term.top)
im->should_delete = 1;
}
scroll_images(-1 * n);
#endif // SIXEL_PATCH
#if SCROLLBACK_PATCH
@ -2106,6 +2090,9 @@ csihandle(void)
{
char buf[40];
int len;
#if SIXEL_PATCH
ImageList *im;
#endif // SIXEL_PATCH
switch (csiescseq.mode[0]) {
default:
@ -2201,6 +2188,16 @@ csihandle(void)
tputtab(csiescseq.arg[0]);
break;
case 'J': /* ED -- Clear screen */
#if SIXEL_PATCH
/* purge sixels */
/* TODO: kinda gross, should probably make this only purge
* visible sixels */
for (im = term.images; im; im = im->next) {
im->should_delete = 1;
}
#endif // SIXEL_PATCH
switch (csiescseq.arg[0]) {
case 0: /* below */
tclearregion(term.c.x, term.c.y, term.col-1, term.c.y);
@ -2237,7 +2234,9 @@ csihandle(void)
break;
case 'S': /* SU -- Scroll <n> line up */
DEFAULT(csiescseq.arg[0], 1);
#if SCROLLBACK_PATCH
#if SIXEL_PATCH && SCROLLBACK_PATCH
tscrollup(term.top, csiescseq.arg[0], 1);
#elif SCROLLBACK_PATCH
tscrollup(term.top, csiescseq.arg[0], 0);
#else
tscrollup(term.top, csiescseq.arg[0]);
@ -2245,7 +2244,9 @@ csihandle(void)
break;
case 'T': /* SD -- Scroll <n> line down */
DEFAULT(csiescseq.arg[0], 1);
#if SCROLLBACK_PATCH
#if SIXEL_PATCH && SCROLLBACK_PATCH
tscrolldown(term.top, csiescseq.arg[0], 1);
#elif SCROLLBACK_PATCH
tscrolldown(term.top, csiescseq.arg[0], 0);
#else
tscrolldown(term.top, csiescseq.arg[0]);
@ -2308,6 +2309,12 @@ csihandle(void)
case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */
tcursor(CURSOR_LOAD);
break;
#if SIXEL_PATCH
case 't':
/* TODO should probably not be hard-coded */
ttywrite(";420;720t", 10, 1);
break;
#endif // SIXEL_PATCH
case ' ':
switch (csiescseq.mode[1]) {
case 'q': /* DECSCUSR -- Set Cursor Style */
@ -2404,6 +2411,9 @@ strhandle(void)
else
redraw();
break;
#elif SIXEL_PATCH
ttywrite("10;rgb:0000/0000/0000", 21, 1);
return;
#endif // OSC_10_11_12_2_PATCH
case 11: /* background set */
#if OSC_10_11_12_2_PATCH
@ -2416,6 +2426,9 @@ strhandle(void)
else
redraw();
break;
#elif SIXEL_PATCH
ttywrite("11;rgb:ffff/ffff/ffff", 21, 1);
return;
#endif // OSC_10_11_12_2_PATCH
case 12: /* cursor color */
#if OSC_10_11_12_2_PATCH

3
x.c
View File

@ -2028,8 +2028,9 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
g.bg = defaultrcs;
} else {
#if DYNAMIC_CURSOR_COLOR_PATCH
unsigned int tmpcol = g.bg;
g.bg = g.fg;
g.fg = defaultbg;
g.fg = tmpcol;
#else
g.fg = defaultbg;
g.bg = defaultcs;