fix a few bugs in sixel

This commit is contained in:
speedie 2022-11-27 11:37:34 +01:00
parent 5ad0db7949
commit 186cf03d68
4 changed files with 46 additions and 21 deletions

View file

@ -32,12 +32,12 @@ clean:
rm -f st $(OBJ) st-$(VERSION).tar.gz
dist: clean
mkdir -p st-$(VERSION)
mkdir -p st-spde-$(VERSION)
cp -R LICENSE Makefile *.mk \
*.h *.info *.c *.desktop *.png docs/ scripts/ \
st-$(VERSION)
tar -cf - st-$(VERSION) | gzip > st-$(VERSION).tar.gz
rm -rf st-$(VERSION)
st-spde-$(VERSION)
tar -cf - st-spde-$(VERSION) | gzip > st-spde-$(VERSION).tar.gz
rm -rf st-spde-$(VERSION)
install: st
mkdir -p $(DESTDIR)$(PREFIX)/bin

View file

@ -27,6 +27,8 @@ static Shortcut shortcuts[] = {
{ CONTROL|SHIFT, XK_H, kexec, {.scmd = "st_help" } },
{ CONTROL|SHIFT, XK_E, kexec, {.scmd = "$EDITOR" } },
{ CONTROL|SHIFT, XK_D, kexec, {.scmd = "$PERM !!" } },
{ CONTROL|SHIFT, XK_F, kexec, {.scmd = "$EDITOR $(find ~/.config -type f | fzf)" } },
{ CONTROL|SHIFT, XK_S, kexec, {.scmd = "$EDITOR $(find ~/Scripts -type f | fzf)" } },
{ CONTROL|SHIFT, XK_K, kscrollup, {.i = -1} },
{ CONTROL|SHIFT, XK_J, kscrolldown, {.i = -1} },
{ CONTROL|SHIFT, XK_U, externalpipeout,{.v = listurl } },

View file

@ -1,5 +1,4 @@
#!/bin/sh
#
clear
echo "This is a test of the st help keybind!"

56
st.c
View file

@ -180,6 +180,7 @@ static void ttywriteraw(const char *, size_t);
static void csidump(void);
static void dcshandle(void);
static void scroll_images(int n);
static void csihandle(void);
static void readcolonargs(char **, int, int[][CAR_PER_ARG]);
static void csiparse(void);
@ -1218,10 +1219,7 @@ kscrolldown(const Arg* a)
tfulldirt();
}
/* TODO: Implement proper scrollback support
* For now, this will do */
for (im = term.sixel.images; im; im = im->next)
im->should_delete = 1;
scroll_images(-1*n);
}
void
@ -1245,10 +1243,14 @@ kscrollup(const Arg* a)
tfulldirt();
}
/* TODO: Implement proper scrollback support
* For now, this will do */
for (im = term.sixel.images; im; im = im->next)
im->should_delete = 1;
if (term.scr + n > term.histi)
n = term.histi - term.scr;
if (!n)
return;
scroll_images(n);
}
void
@ -1276,17 +1278,37 @@ tscrolldown(int orig, int n, int copyhist)
term.line[i-n] = temp;
}
scroll_images(n);
if (term.scr == 0)
selscroll(orig, n);
/* TODO: Implement proper scrollback support
* For now, this will do */
for (im = term.sixel.images; im; im = im->next)
im->should_delete = 1;
/* process scrolldown */
xsixelscrolldown(&term.sixel, n, term.bot);
}
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.sixel.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;
}
}
}
void
@ -1294,7 +1316,6 @@ tscrollup(int orig, int n, int copyhist)
{
int i;
Line temp;
ImageList *im;
LIMIT(n, 0, term.bot-orig+1);
@ -1317,6 +1338,8 @@ tscrollup(int orig, int n, int copyhist)
term.line[i+n] = temp;
}
scroll_images(-1*n);
/* process scrollup */
xsixelscrollup(&term.sixel, n, term.top);
@ -1894,6 +1917,7 @@ csihandle(void)
{
char buf[40];
int len;
ImageList *im;
switch (csiescseq.mode[0]) {
default:
@ -2025,11 +2049,11 @@ csihandle(void)
break;
case 'S': /* SU -- Scroll <n> line up */
DEFAULT(csiescseq.arg[0], 1);
tscrollup(term.top, csiescseq.arg[0], 0);
tscrollup(term.top, csiescseq.arg[0], 1);
break;
case 'T': /* SD -- Scroll <n> line down */
DEFAULT(csiescseq.arg[0], 1);
tscrolldown(term.top, csiescseq.arg[0], 0);
tscrolldown(term.top, csiescseq.arg[0], 1);
break;
case 'L': /* IL -- Insert <n> blank lines */
DEFAULT(csiescseq.arg[0], 1);