Skip to content

Commit

Permalink
Adding sixel support ref. #7
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkeby committed Mar 25, 2021
1 parent 884c62a commit f31c430
Show file tree
Hide file tree
Showing 17 changed files with 1,260 additions and 156 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ include config.mk
#LIGATURES_C = hb.c
#LIGATURES_H = hb.h

SRC = st.c x.c $(LIGATURES_C)
# Uncomment this for the SIXEL patch / SIXEL_PATCH
#SIXEL_C = sixel.c sixel_hls.c

SRC = st.c x.c $(LIGATURES_C) $(SIXEL_C)
OBJ = $(SRC:.c=.o)

all: options st
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
### Changelog:
2021-03-10 - Added sixel support
2021-02-26 - Added the dynamic cursor color patch
2021-02-15 - Added the alpha gradient patch
Expand Down Expand Up @@ -145,6 +147,9 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
- [scrollback](https://st.suckless.org/patches/scrollback/)
- allows you scroll back through terminal output using keyboard shortcuts or mousewheel
- sixel
- this patch adds SIXEL graphics support
- st-embedder
- this patch allows clients to embed into the st window and can be useful if you tend to start X applications from the terminal
- the behavior is similar to Plan 9 where applications can take over windows
Expand Down
2 changes: 1 addition & 1 deletion config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ X11LIB = /usr/X11R6/lib
PKG_CONFIG = pkg-config

# Uncomment this for the alpha patch / ALPHA_PATCH
XRENDER = -lXrender
#XRENDER = -lXrender

# Uncomment this for the themed cursor patch / THEMED_CURSOR_PATCH
#XCURSOR = -lXcursor
Expand Down
18 changes: 18 additions & 0 deletions patch/sixel_st.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
sixel_state_t sixel_st;

void
dcshandle(void)
{
switch (csiescseq.mode[0]) {
default:
fprintf(stderr, "erresc: unknown csi ");
csidump();
/* die(""); */
break;
case 'q': /* DECSIXEL */
if (sixel_parser_init(&sixel_st, 0, 0 << 16 | 0 << 8 | 0, 1, win.cw, win.ch) != 0)
perror("sixel_parser_init() failed");
term.mode |= MODE_SIXEL;
break;
}
}
1 change: 1 addition & 0 deletions patch/sixel_st.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
static void dcshandle(void);
14 changes: 14 additions & 0 deletions patch/sixel_x.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
void
delete_image(ImageList *im)
{
if (im->prev)
im->prev->next = im->next;
else
term.images = im->next;
if (im->next)
im->next->prev = im->prev;
if (im->pixmap)
XFreePixmap(xw.dpy, (Drawable)im->pixmap);
free(im->pixels);
free(im);
}
3 changes: 3 additions & 0 deletions patch/st_include.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
#endif
#if SCROLLBACK_PATCH || SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
#include "scrollback.c"
#endif
#if SIXEL_PATCH
#include "sixel_st.c"
#endif
3 changes: 3 additions & 0 deletions patch/st_include.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@
#endif
#if SCROLLBACK_PATCH || SCROLLBACK_MOUSE_PATCH || SCROLLBACK_MOUSE_ALTSCREEN_PATCH
#include "scrollback.h"
#endif
#if SIXEL_PATCH
#include "sixel_st.h"
#endif
3 changes: 3 additions & 0 deletions patch/x_include.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#if RIGHTCLICKTOPLUMB_PATCH
#include "rightclicktoplumb_x.c"
#endif
#if SIXEL_PATCH
#include "sixel_x.c"
#endif
#if ST_EMBEDDER_PATCH
#include "st_embedder_x.c"
#endif
Expand Down
20 changes: 20 additions & 0 deletions patches.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,26 @@
*/
#define SINGLE_DRAWABLE_BUFFER_PATCH 0

/* This patch adds SIXEL graphics support for st.
* Note that patch/sixel.c/sixel_hls.c come from mintty, licensed under GPL.
* Known issues:
* - Entering clear causes all sixels to be deleted from scrollback.
* - Rendering sixel graphics may cause unusual cursor placement, this is
* not specific to this variant of st - the same issue is present in
* the xterm implementation. This is likely an issue of sixel height
* not being detected correctly.
* - If combined with the alpha patch sixel graphics disappear (become white)
* when transparent and rendered against a white background. This is believed
* to be related to how the sixel graphics use RGB colors instead of RGBA.
* A pull request or instructions for how to properly add alpha support for
* sixel graphics would be very welcome.
*
* Note that you need to uncomment the corresponding lines in Makefile when including this patch.
*
* https://gist.github.com/saitoha/70e0fdf22e3e8f63ce937c7f7da71809
*/
#define SIXEL_PATCH 0

/* This patch allows clients to embed into the st window and is useful if you tend to
* start X applications from the terminal. For example:
*
Expand Down
Loading

0 comments on commit f31c430

Please sign in to comment.