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); selscroll(0, -n);
tfulldirt(); tfulldirt();
} }
#if SIXEL_PATCH
scroll_images(-1*n);
#endif // SIXEL_PATCH
} }
void void
@ -28,4 +32,8 @@ kscrollup(const Arg* a)
selscroll(0, n); selscroll(0, n);
tfulldirt(); tfulldirt();
} }
#if SIXEL_PATCH
scroll_images(n);
#endif // SIXEL_PATCH
} }

View File

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