mirror of
https://github.com/tiyn/st
synced 2025-10-14 12:01:15 +02:00
Compare commits
18 Commits
3bd944753f
...
master
Author | SHA1 | Date | |
---|---|---|---|
b261346926 | |||
1bdc902c7f | |||
11b713eaa8 | |||
48edd00a2b | |||
b141801a78 | |||
65cd29200a | |||
16a80ff6ee | |||
a9a0a93e7c | |||
468db95358 | |||
7cfbffad2a | |||
f9a98e5a46 | |||
ff9b014af8 | |||
5500f49c69 | |||
490ff19562 | |||
d6315b6054 | |||
38c5d4fd4c | |||
f2f92955cc | |||
45c5e9b3c1 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -50,3 +50,5 @@ modules.order
|
|||||||
Module.symvers
|
Module.symvers
|
||||||
Mkfile.old
|
Mkfile.old
|
||||||
dkms.conf
|
dkms.conf
|
||||||
|
|
||||||
|
st
|
||||||
|
4
Makefile
4
Makefile
@@ -44,7 +44,9 @@ dist: clean
|
|||||||
install: st
|
install: st
|
||||||
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||||
cp -f st $(DESTDIR)$(PREFIX)/bin
|
cp -f st $(DESTDIR)$(PREFIX)/bin
|
||||||
|
cp -f st-copyout $(DESTDIR)$(PREFIX)/bin
|
||||||
chmod 755 $(DESTDIR)$(PREFIX)/bin/st
|
chmod 755 $(DESTDIR)$(PREFIX)/bin/st
|
||||||
|
chmod 755 $(DESTDIR)$(PREFIX)/bin/st-copyout
|
||||||
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
|
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
|
||||||
sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1
|
sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1
|
||||||
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1
|
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1
|
||||||
@@ -53,6 +55,8 @@ install: st
|
|||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -f $(DESTDIR)$(PREFIX)/bin/st
|
rm -f $(DESTDIR)$(PREFIX)/bin/st
|
||||||
|
rm -f $(DESTDIR)$(PREFIX)/bin/st-copyout
|
||||||
|
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
|
||||||
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
|
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
|
||||||
|
|
||||||
.PHONY: all options clean dist install uninstall
|
.PHONY: all options clean dist install uninstall
|
||||||
|
41
README.md
41
README.md
@@ -8,8 +8,10 @@ It is supposed to work in the environment after the larbs-base-installation.
|
|||||||
|
|
||||||
The list below shows the currently applied patches to the master branch.
|
The list below shows the currently applied patches to the master branch.
|
||||||
|
|
||||||
|
- st-alpha-20220206-0.8.5.diff (adds transparency)
|
||||||
- st-anysize-20220718-baa9357.diff (st leaves no gaps if the height/width doesn't match a multiple of
|
- st-anysize-20220718-baa9357.diff (st leaves no gaps if the height/width doesn't match a multiple of
|
||||||
character height)
|
character height)
|
||||||
|
- st-externalpipe-0.8.4.diff (allows reading and writing st's screen through a pipe)
|
||||||
- st-ligatures-scrollback-20230105-0.9.diff (scrollback compatible addition of ligatures)
|
- st-ligatures-scrollback-20230105-0.9.diff (scrollback compatible addition of ligatures)
|
||||||
- st-scrollback-0.8.5.diff (add scrollback functionality)
|
- st-scrollback-0.8.5.diff (add scrollback functionality)
|
||||||
|
|
||||||
@@ -17,30 +19,27 @@ The list below shows the currently applied patches to the master branch.
|
|||||||
|
|
||||||
There are various shortcuts and hotkeys used in this version. Included in my build are the following.
|
There are various shortcuts and hotkeys used in this version. Included in my build are the following.
|
||||||
|
|
||||||
| ModKey | Shift | Key | Function |
|
| ModKey | Shift | Key | Function |
|
||||||
| ------ | ----- | --------------- | --------------- |
|
| ------ | ----- | --------------- | -------------------------------------------- |
|
||||||
| Alt | | Break | Send break |
|
| Alt | | Break | Send break |
|
||||||
| Alt | | Print | Toggle printer |
|
| Alt | | Print | Toggle printer |
|
||||||
| Alt | | Print | Print screen |
|
| Alt | | Print | Print screen |
|
||||||
| | Shift | Insert | Clipboard paste |
|
| | Shift | Insert | Clipboard paste |
|
||||||
| Alt | | c | Clipboard copy |
|
| Alt | | c | Clipboard copy |
|
||||||
| Alt | | v | Clipboard paste |
|
| Alt | | v | Clipboard paste |
|
||||||
| Alt | | p | Selected paste |
|
| Alt | | p | Selected paste |
|
||||||
| Alt | | NumLock | Toggle Numlock |
|
| Alt | | NumLock | Toggle Numlock |
|
||||||
| Alt | | k | Scroll up |
|
| Alt | | k | Scroll up |
|
||||||
| Alt | | j | Scroll down |
|
| Alt | | j | Scroll down |
|
||||||
| | | MouseScrollUp | Scroll up |
|
| | | MouseScrollUp | Scroll up |
|
||||||
| | | MouseScrollDown | Scroll down |
|
| | | MouseScrollDown | Scroll down |
|
||||||
| Alt | Shift | u | Zoom in |
|
| Alt | Shift | u | Zoom in |
|
||||||
| Alt | Shift | i | Zoom out |
|
| Alt | Shift | i | Zoom out |
|
||||||
|
| Alt | | o | copy output of previous command to clipboard |
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
To install this package you can run several commands.
|
|
||||||
If you want to use st with colored emojis make sure to install `libxft-bgra`
|
|
||||||
(`yay -S libxft-bgra` on arch based systems`).
|
|
||||||
|
|
||||||
The most basic way is to clone the repository and then invoke make.
|
The most basic way is to clone the repository and then invoke make.
|
||||||
|
|
||||||
- `git clone https://github.com/tiyn/st-0.9.0`
|
- `git clone https://github.com/tiyn/st`
|
||||||
- `make clean install`
|
- `make clean install`
|
||||||
|
12
config.def.h
12
config.def.h
@@ -93,10 +93,13 @@ char *termname = "st-256color";
|
|||||||
*/
|
*/
|
||||||
unsigned int tabspaces = 8;
|
unsigned int tabspaces = 8;
|
||||||
|
|
||||||
|
/* bg opacity */
|
||||||
|
float alpha = 1.0;
|
||||||
|
|
||||||
/* Terminal colors (16 first used in escape sequence) */
|
/* Terminal colors (16 first used in escape sequence) */
|
||||||
static const char *colorname[] = {
|
static const char *colorname[] = {
|
||||||
/* 8 normal colors */
|
/* 8 normal colors */
|
||||||
"#1e1e1e",
|
"#191919",
|
||||||
"#f44747",
|
"#f44747",
|
||||||
"#608b4e",
|
"#608b4e",
|
||||||
"#dcdcaa",
|
"#dcdcaa",
|
||||||
@@ -114,9 +117,9 @@ static const char *colorname[] = {
|
|||||||
"#d4d4d4",
|
"#d4d4d4",
|
||||||
[255] = 0,
|
[255] = 0,
|
||||||
/* more colors can be added after 255 to use with DefaultXX */
|
/* more colors can be added after 255 to use with DefaultXX */
|
||||||
"#1e1e1e", /* 256 -> bg */
|
"#191919", /* 256 -> bg */
|
||||||
"#d4d4d4", /* 257 -> fg */
|
"#d4d4d4", /* 257 -> fg */
|
||||||
"#d4d4d4", /* 258 -> cursor */
|
"#a4a4a4", /* 258 -> cursor */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -181,6 +184,8 @@ static MouseShortcut mshortcuts[] = {
|
|||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod1Mask
|
||||||
#define TERMMOD (ControlMask|ShiftMask)
|
#define TERMMOD (ControlMask|ShiftMask)
|
||||||
|
|
||||||
|
static char *copyoutput[] = { "/bin/sh", "-c", "st-copyout", "externalpipe", NULL };
|
||||||
|
|
||||||
static Shortcut shortcuts[] = {
|
static Shortcut shortcuts[] = {
|
||||||
/* mask keysym function argument */
|
/* mask keysym function argument */
|
||||||
{ MODKEY, XK_Break, sendbreak, {.i = 0} },
|
{ MODKEY, XK_Break, sendbreak, {.i = 0} },
|
||||||
@@ -196,6 +201,7 @@ static Shortcut shortcuts[] = {
|
|||||||
{ MODKEY, XK_U, zoom, {.f = +1} },
|
{ MODKEY, XK_U, zoom, {.f = +1} },
|
||||||
{ MODKEY|ShiftMask, XK_U, zoom, {.f = +1} },
|
{ MODKEY|ShiftMask, XK_U, zoom, {.f = +1} },
|
||||||
{ MODKEY|ShiftMask, XK_I, zoom, {.f = -1} },
|
{ MODKEY|ShiftMask, XK_I, zoom, {.f = -1} },
|
||||||
|
{ MODKEY, XK_o, externalpipe, {.v = copyoutput } },
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -17,7 +17,7 @@ INCS = -I$(X11INC) \
|
|||||||
`$(PKG_CONFIG) --cflags fontconfig` \
|
`$(PKG_CONFIG) --cflags fontconfig` \
|
||||||
`$(PKG_CONFIG) --cflags freetype2` \
|
`$(PKG_CONFIG) --cflags freetype2` \
|
||||||
`$(PKG_CONFIG) --cflags harfbuzz`
|
`$(PKG_CONFIG) --cflags harfbuzz`
|
||||||
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
|
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender\
|
||||||
`$(PKG_CONFIG) --libs fontconfig` \
|
`$(PKG_CONFIG) --libs fontconfig` \
|
||||||
`$(PKG_CONFIG) --libs freetype2` \
|
`$(PKG_CONFIG) --libs freetype2` \
|
||||||
`$(PKG_CONFIG) --libs harfbuzz`
|
`$(PKG_CONFIG) --libs harfbuzz`
|
||||||
|
146
st-alpha-20220206-0.8.5.diff
Normal file
146
st-alpha-20220206-0.8.5.diff
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 91ab8ca..6af616e 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -93,6 +93,9 @@ char *termname = "st-256color";
|
||||||
|
*/
|
||||||
|
unsigned int tabspaces = 8;
|
||||||
|
|
||||||
|
+/* bg opacity */
|
||||||
|
+float alpha = 0.8;
|
||||||
|
+
|
||||||
|
/* Terminal colors (16 first used in escape sequence) */
|
||||||
|
static const char *colorname[] = {
|
||||||
|
/* 8 normal colors */
|
||||||
|
diff --git a/config.mk b/config.mk
|
||||||
|
index 4c4c5d5..0114bad 100644
|
||||||
|
--- a/config.mk
|
||||||
|
+++ b/config.mk
|
||||||
|
@@ -16,7 +16,7 @@ PKG_CONFIG = pkg-config
|
||||||
|
INCS = -I$(X11INC) \
|
||||||
|
`$(PKG_CONFIG) --cflags fontconfig` \
|
||||||
|
`$(PKG_CONFIG) --cflags freetype2`
|
||||||
|
-LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
|
||||||
|
+LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender\
|
||||||
|
`$(PKG_CONFIG) --libs fontconfig` \
|
||||||
|
`$(PKG_CONFIG) --libs freetype2`
|
||||||
|
|
||||||
|
diff --git a/st.h b/st.h
|
||||||
|
index 519b9bd..8bb533d 100644
|
||||||
|
--- a/st.h
|
||||||
|
+++ b/st.h
|
||||||
|
@@ -126,3 +126,4 @@ extern unsigned int tabspaces;
|
||||||
|
extern unsigned int defaultfg;
|
||||||
|
extern unsigned int defaultbg;
|
||||||
|
extern unsigned int defaultcs;
|
||||||
|
+extern float alpha;
|
||||||
|
diff --git a/x.c b/x.c
|
||||||
|
index 8a16faa..ddf4178 100644
|
||||||
|
--- a/x.c
|
||||||
|
+++ b/x.c
|
||||||
|
@@ -105,6 +105,7 @@ typedef struct {
|
||||||
|
XSetWindowAttributes attrs;
|
||||||
|
int scr;
|
||||||
|
int isfixed; /* is fixed geometry? */
|
||||||
|
+ int depth; /* bit depth */
|
||||||
|
int l, t; /* left and top offset */
|
||||||
|
int gm; /* geometry mask */
|
||||||
|
} XWindow;
|
||||||
|
@@ -243,6 +244,7 @@ static char *usedfont = NULL;
|
||||||
|
static double usedfontsize = 0;
|
||||||
|
static double defaultfontsize = 0;
|
||||||
|
|
||||||
|
+static char *opt_alpha = NULL;
|
||||||
|
static char *opt_class = NULL;
|
||||||
|
static char **opt_cmd = NULL;
|
||||||
|
static char *opt_embed = NULL;
|
||||||
|
@@ -736,7 +738,7 @@ xresize(int col, int row)
|
||||||
|
|
||||||
|
XFreePixmap(xw.dpy, xw.buf);
|
||||||
|
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
||||||
|
- DefaultDepth(xw.dpy, xw.scr));
|
||||||
|
+ xw.depth);
|
||||||
|
XftDrawChange(xw.draw, xw.buf);
|
||||||
|
xclear(0, 0, win.w, win.h);
|
||||||
|
|
||||||
|
@@ -796,6 +798,13 @@ xloadcols(void)
|
||||||
|
else
|
||||||
|
die("could not allocate color %d\n", i);
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ /* set alpha value of bg color */
|
||||||
|
+ if (opt_alpha)
|
||||||
|
+ alpha = strtof(opt_alpha, NULL);
|
||||||
|
+ dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
|
||||||
|
+ dc.col[defaultbg].pixel &= 0x00FFFFFF;
|
||||||
|
+ dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;
|
||||||
|
loaded = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1118,11 +1127,23 @@ xinit(int cols, int rows)
|
||||||
|
Window parent;
|
||||||
|
pid_t thispid = getpid();
|
||||||
|
XColor xmousefg, xmousebg;
|
||||||
|
+ XWindowAttributes attr;
|
||||||
|
+ XVisualInfo vis;
|
||||||
|
|
||||||
|
if (!(xw.dpy = XOpenDisplay(NULL)))
|
||||||
|
die("can't open display\n");
|
||||||
|
xw.scr = XDefaultScreen(xw.dpy);
|
||||||
|
- xw.vis = XDefaultVisual(xw.dpy, xw.scr);
|
||||||
|
+
|
||||||
|
+ if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) {
|
||||||
|
+ parent = XRootWindow(xw.dpy, xw.scr);
|
||||||
|
+ xw.depth = 32;
|
||||||
|
+ } else {
|
||||||
|
+ XGetWindowAttributes(xw.dpy, parent, &attr);
|
||||||
|
+ xw.depth = attr.depth;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ XMatchVisualInfo(xw.dpy, xw.scr, xw.depth, TrueColor, &vis);
|
||||||
|
+ xw.vis = vis.visual;
|
||||||
|
|
||||||
|
/* font */
|
||||||
|
if (!FcInit())
|
||||||
|
@@ -1132,7 +1153,7 @@ xinit(int cols, int rows)
|
||||||
|
xloadfonts(usedfont, 0);
|
||||||
|
|
||||||
|
/* colors */
|
||||||
|
- xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
|
||||||
|
+ xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None);
|
||||||
|
xloadcols();
|
||||||
|
|
||||||
|
/* adjust fixed window geometry */
|
||||||
|
@@ -1152,19 +1173,15 @@ xinit(int cols, int rows)
|
||||||
|
| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
|
||||||
|
xw.attrs.colormap = xw.cmap;
|
||||||
|
|
||||||
|
- if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
|
||||||
|
- parent = XRootWindow(xw.dpy, xw.scr);
|
||||||
|
xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t,
|
||||||
|
- win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput,
|
||||||
|
+ win.w, win.h, 0, xw.depth, InputOutput,
|
||||||
|
xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity
|
||||||
|
| CWEventMask | CWColormap, &xw.attrs);
|
||||||
|
|
||||||
|
memset(&gcvalues, 0, sizeof(gcvalues));
|
||||||
|
gcvalues.graphics_exposures = False;
|
||||||
|
- dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
|
||||||
|
- &gcvalues);
|
||||||
|
- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
||||||
|
- DefaultDepth(xw.dpy, xw.scr));
|
||||||
|
+ xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, xw.depth);
|
||||||
|
+ dc.gc = XCreateGC(xw.dpy, xw.buf, GCGraphicsExposures, &gcvalues);
|
||||||
|
XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
|
||||||
|
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
|
||||||
|
|
||||||
|
@@ -2019,6 +2036,9 @@ main(int argc, char *argv[])
|
||||||
|
case 'a':
|
||||||
|
allowaltscreen = 0;
|
||||||
|
break;
|
||||||
|
+ case 'A':
|
||||||
|
+ opt_alpha = EARGF(usage());
|
||||||
|
+ break;
|
||||||
|
case 'c':
|
||||||
|
opt_class = EARGF(usage());
|
||||||
|
break;
|
13
st-copyout
Normal file
13
st-copyout
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Using external pipe with st, give a dmenu prompt of recent commands,
|
||||||
|
# allowing the user to copy the output of one.
|
||||||
|
# xclip required for this script.
|
||||||
|
# By Jaywalker and Luke
|
||||||
|
tmpfile=$(mktemp /tmp/st-cmd-output.XXXXXX)
|
||||||
|
trap 'rm "$tmpfile"' 0 1 15
|
||||||
|
sed -n "w $tmpfile"
|
||||||
|
sed -i 's/\x0//g' "$tmpfile"
|
||||||
|
ps1="$(grep "\S" "$tmpfile" | tail -n 1 | sed 's/^\s*//' | cut -d' ' -f1)"
|
||||||
|
chosen="$(grep -F "$ps1" "$tmpfile" | sed '$ d' | tac | dmenu -p "Copy which command's output?" -i -l 10 | sed 's/[^^]/[&]/g; s/\^/\\^/g')"
|
||||||
|
eps1="$(echo "$ps1" | sed 's/[^^]/[&]/g; s/\^/\\^/g')"
|
||||||
|
awk "/^$chosen$/{p=1;print;next} p&&/$eps1/{p=0};p" "$tmpfile" | xclip -selection clipboard
|
92
st-externalpipe-0.8.4.diff
Normal file
92
st-externalpipe-0.8.4.diff
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
diff --git a/st.c b/st.c
|
||||||
|
index 76b7e0d..0e9a614 100644
|
||||||
|
--- a/st.c
|
||||||
|
+++ b/st.c
|
||||||
|
@@ -723,8 +723,14 @@ sigchld(int a)
|
||||||
|
if ((p = waitpid(pid, &stat, WNOHANG)) < 0)
|
||||||
|
die("waiting for pid %hd failed: %s\n", pid, strerror(errno));
|
||||||
|
|
||||||
|
- if (pid != p)
|
||||||
|
+ if (pid != p) {
|
||||||
|
+ if (p == 0 && wait(&stat) < 0)
|
||||||
|
+ die("wait: %s\n", strerror(errno));
|
||||||
|
+
|
||||||
|
+ /* reinstall sigchld handler */
|
||||||
|
+ signal(SIGCHLD, sigchld);
|
||||||
|
return;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
if (WIFEXITED(stat) && WEXITSTATUS(stat))
|
||||||
|
die("child exited with status %d\n", WEXITSTATUS(stat));
|
||||||
|
@@ -1926,6 +1932,59 @@ strparse(void)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+externalpipe(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ int to[2];
|
||||||
|
+ char buf[UTF_SIZ];
|
||||||
|
+ void (*oldsigpipe)(int);
|
||||||
|
+ Glyph *bp, *end;
|
||||||
|
+ int lastpos, n, newline;
|
||||||
|
+
|
||||||
|
+ if (pipe(to) == -1)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ switch (fork()) {
|
||||||
|
+ case -1:
|
||||||
|
+ close(to[0]);
|
||||||
|
+ close(to[1]);
|
||||||
|
+ return;
|
||||||
|
+ case 0:
|
||||||
|
+ dup2(to[0], STDIN_FILENO);
|
||||||
|
+ close(to[0]);
|
||||||
|
+ close(to[1]);
|
||||||
|
+ execvp(((char **)arg->v)[0], (char **)arg->v);
|
||||||
|
+ fprintf(stderr, "st: execvp %s\n", ((char **)arg->v)[0]);
|
||||||
|
+ perror("failed");
|
||||||
|
+ exit(0);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ close(to[0]);
|
||||||
|
+ /* ignore sigpipe for now, in case child exists early */
|
||||||
|
+ oldsigpipe = signal(SIGPIPE, SIG_IGN);
|
||||||
|
+ newline = 0;
|
||||||
|
+ for (n = 0; n < term.row; n++) {
|
||||||
|
+ bp = term.line[n];
|
||||||
|
+ lastpos = MIN(tlinelen(n) + 1, term.col) - 1;
|
||||||
|
+ if (lastpos < 0)
|
||||||
|
+ break;
|
||||||
|
+ end = &bp[lastpos + 1];
|
||||||
|
+ for (; bp < end; ++bp)
|
||||||
|
+ if (xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0)
|
||||||
|
+ break;
|
||||||
|
+ if ((newline = term.line[n][lastpos].mode & ATTR_WRAP))
|
||||||
|
+ continue;
|
||||||
|
+ if (xwrite(to[1], "\n", 1) < 0)
|
||||||
|
+ break;
|
||||||
|
+ newline = 0;
|
||||||
|
+ }
|
||||||
|
+ if (newline)
|
||||||
|
+ (void)xwrite(to[1], "\n", 1);
|
||||||
|
+ close(to[1]);
|
||||||
|
+ /* restore */
|
||||||
|
+ signal(SIGPIPE, oldsigpipe);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
strdump(void)
|
||||||
|
{
|
||||||
|
diff --git a/st.h b/st.h
|
||||||
|
index 3d351b6..392b64e 100644
|
||||||
|
--- a/st.h
|
||||||
|
+++ b/st.h
|
||||||
|
@@ -81,6 +81,7 @@ void die(const char *, ...);
|
||||||
|
void redraw(void);
|
||||||
|
void draw(void);
|
||||||
|
|
||||||
|
+void externalpipe(const Arg *);
|
||||||
|
void printscreen(const Arg *);
|
||||||
|
void printsel(const Arg *);
|
||||||
|
void sendbreak(const Arg *);
|
61
st.c
61
st.c
@@ -725,8 +725,14 @@ sigchld(int a)
|
|||||||
if ((p = waitpid(pid, &stat, WNOHANG)) < 0)
|
if ((p = waitpid(pid, &stat, WNOHANG)) < 0)
|
||||||
die("waiting for pid %hd failed: %s\n", pid, strerror(errno));
|
die("waiting for pid %hd failed: %s\n", pid, strerror(errno));
|
||||||
|
|
||||||
if (pid != p)
|
if (pid != p) {
|
||||||
|
if (p == 0 && wait(&stat) < 0)
|
||||||
|
die("wait: %s\n", strerror(errno));
|
||||||
|
|
||||||
|
/* reinstall sigchld handler */
|
||||||
|
signal(SIGCHLD, sigchld);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (WIFEXITED(stat) && WEXITSTATUS(stat))
|
if (WIFEXITED(stat) && WEXITSTATUS(stat))
|
||||||
die("child exited with status %d\n", WEXITSTATUS(stat));
|
die("child exited with status %d\n", WEXITSTATUS(stat));
|
||||||
@@ -2043,6 +2049,59 @@ strparse(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
externalpipe(const Arg *arg)
|
||||||
|
{
|
||||||
|
int to[2];
|
||||||
|
char buf[UTF_SIZ];
|
||||||
|
void (*oldsigpipe)(int);
|
||||||
|
Glyph *bp, *end;
|
||||||
|
int lastpos, n, newline;
|
||||||
|
|
||||||
|
if (pipe(to) == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (fork()) {
|
||||||
|
case -1:
|
||||||
|
close(to[0]);
|
||||||
|
close(to[1]);
|
||||||
|
return;
|
||||||
|
case 0:
|
||||||
|
dup2(to[0], STDIN_FILENO);
|
||||||
|
close(to[0]);
|
||||||
|
close(to[1]);
|
||||||
|
execvp(((char **)arg->v)[0], (char **)arg->v);
|
||||||
|
fprintf(stderr, "st: execvp %s\n", ((char **)arg->v)[0]);
|
||||||
|
perror("failed");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
close(to[0]);
|
||||||
|
/* ignore sigpipe for now, in case child exists early */
|
||||||
|
oldsigpipe = signal(SIGPIPE, SIG_IGN);
|
||||||
|
newline = 0;
|
||||||
|
for (n = 0; n < term.row; n++) {
|
||||||
|
bp = term.line[n];
|
||||||
|
lastpos = MIN(tlinelen(n) + 1, term.col) - 1;
|
||||||
|
if (lastpos < 0)
|
||||||
|
break;
|
||||||
|
end = &bp[lastpos + 1];
|
||||||
|
for (; bp < end; ++bp)
|
||||||
|
if (xwrite(to[1], buf, utf8encode(bp->u, buf)) < 0)
|
||||||
|
break;
|
||||||
|
if ((newline = term.line[n][lastpos].mode & ATTR_WRAP))
|
||||||
|
continue;
|
||||||
|
if (xwrite(to[1], "\n", 1) < 0)
|
||||||
|
break;
|
||||||
|
newline = 0;
|
||||||
|
}
|
||||||
|
if (newline)
|
||||||
|
(void)xwrite(to[1], "\n", 1);
|
||||||
|
close(to[1]);
|
||||||
|
/* restore */
|
||||||
|
signal(SIGPIPE, oldsigpipe);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
strdump(void)
|
strdump(void)
|
||||||
{
|
{
|
||||||
|
2
st.h
2
st.h
@@ -84,6 +84,7 @@ void draw(void);
|
|||||||
|
|
||||||
void kscrolldown(const Arg *);
|
void kscrolldown(const Arg *);
|
||||||
void kscrollup(const Arg *);
|
void kscrollup(const Arg *);
|
||||||
|
void externalpipe(const Arg *);
|
||||||
void printscreen(const Arg *);
|
void printscreen(const Arg *);
|
||||||
void printsel(const Arg *);
|
void printsel(const Arg *);
|
||||||
void sendbreak(const Arg *);
|
void sendbreak(const Arg *);
|
||||||
@@ -127,3 +128,4 @@ extern unsigned int tabspaces;
|
|||||||
extern unsigned int defaultfg;
|
extern unsigned int defaultfg;
|
||||||
extern unsigned int defaultbg;
|
extern unsigned int defaultbg;
|
||||||
extern unsigned int defaultcs;
|
extern unsigned int defaultcs;
|
||||||
|
extern float alpha;
|
||||||
|
40
x.c
40
x.c
@@ -107,6 +107,7 @@ typedef struct {
|
|||||||
XSetWindowAttributes attrs;
|
XSetWindowAttributes attrs;
|
||||||
int scr;
|
int scr;
|
||||||
int isfixed; /* is fixed geometry? */
|
int isfixed; /* is fixed geometry? */
|
||||||
|
int depth; /* bit depth */
|
||||||
int l, t; /* left and top offset */
|
int l, t; /* left and top offset */
|
||||||
int gm; /* geometry mask */
|
int gm; /* geometry mask */
|
||||||
} XWindow;
|
} XWindow;
|
||||||
@@ -246,6 +247,7 @@ static char *usedfont = NULL;
|
|||||||
static double usedfontsize = 0;
|
static double usedfontsize = 0;
|
||||||
static double defaultfontsize = 0;
|
static double defaultfontsize = 0;
|
||||||
|
|
||||||
|
static char *opt_alpha = NULL;
|
||||||
static char *opt_class = NULL;
|
static char *opt_class = NULL;
|
||||||
static char **opt_cmd = NULL;
|
static char **opt_cmd = NULL;
|
||||||
static char *opt_embed = NULL;
|
static char *opt_embed = NULL;
|
||||||
@@ -758,7 +760,7 @@ xresize(int col, int row)
|
|||||||
|
|
||||||
XFreePixmap(xw.dpy, xw.buf);
|
XFreePixmap(xw.dpy, xw.buf);
|
||||||
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
||||||
DefaultDepth(xw.dpy, xw.scr));
|
xw.depth);
|
||||||
XftDrawChange(xw.draw, xw.buf);
|
XftDrawChange(xw.draw, xw.buf);
|
||||||
xclear(0, 0, win.w, win.h);
|
xclear(0, 0, win.w, win.h);
|
||||||
|
|
||||||
@@ -818,6 +820,13 @@ xloadcols(void)
|
|||||||
else
|
else
|
||||||
die("could not allocate color %d\n", i);
|
die("could not allocate color %d\n", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set alpha value of bg color */
|
||||||
|
if (opt_alpha)
|
||||||
|
alpha = strtof(opt_alpha, NULL);
|
||||||
|
dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha);
|
||||||
|
dc.col[defaultbg].pixel &= 0x00FFFFFF;
|
||||||
|
dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24;
|
||||||
loaded = 1;
|
loaded = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1143,11 +1152,23 @@ xinit(int cols, int rows)
|
|||||||
Window parent;
|
Window parent;
|
||||||
pid_t thispid = getpid();
|
pid_t thispid = getpid();
|
||||||
XColor xmousefg, xmousebg;
|
XColor xmousefg, xmousebg;
|
||||||
|
XWindowAttributes attr;
|
||||||
|
XVisualInfo vis;
|
||||||
|
|
||||||
if (!(xw.dpy = XOpenDisplay(NULL)))
|
if (!(xw.dpy = XOpenDisplay(NULL)))
|
||||||
die("can't open display\n");
|
die("can't open display\n");
|
||||||
xw.scr = XDefaultScreen(xw.dpy);
|
xw.scr = XDefaultScreen(xw.dpy);
|
||||||
xw.vis = XDefaultVisual(xw.dpy, xw.scr);
|
|
||||||
|
if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) {
|
||||||
|
parent = XRootWindow(xw.dpy, xw.scr);
|
||||||
|
xw.depth = 32;
|
||||||
|
} else {
|
||||||
|
XGetWindowAttributes(xw.dpy, parent, &attr);
|
||||||
|
xw.depth = attr.depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMatchVisualInfo(xw.dpy, xw.scr, xw.depth, TrueColor, &vis);
|
||||||
|
xw.vis = vis.visual;
|
||||||
|
|
||||||
/* font */
|
/* font */
|
||||||
if (!FcInit())
|
if (!FcInit())
|
||||||
@@ -1157,7 +1178,7 @@ xinit(int cols, int rows)
|
|||||||
xloadfonts(usedfont, 0);
|
xloadfonts(usedfont, 0);
|
||||||
|
|
||||||
/* colors */
|
/* colors */
|
||||||
xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
|
xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None);
|
||||||
xloadcols();
|
xloadcols();
|
||||||
|
|
||||||
/* adjust fixed window geometry */
|
/* adjust fixed window geometry */
|
||||||
@@ -1177,19 +1198,15 @@ xinit(int cols, int rows)
|
|||||||
| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
|
| ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
|
||||||
xw.attrs.colormap = xw.cmap;
|
xw.attrs.colormap = xw.cmap;
|
||||||
|
|
||||||
if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
|
|
||||||
parent = XRootWindow(xw.dpy, xw.scr);
|
|
||||||
xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t,
|
xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t,
|
||||||
win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput,
|
win.w, win.h, 0, xw.depth, InputOutput,
|
||||||
xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity
|
xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity
|
||||||
| CWEventMask | CWColormap, &xw.attrs);
|
| CWEventMask | CWColormap, &xw.attrs);
|
||||||
|
|
||||||
memset(&gcvalues, 0, sizeof(gcvalues));
|
memset(&gcvalues, 0, sizeof(gcvalues));
|
||||||
gcvalues.graphics_exposures = False;
|
gcvalues.graphics_exposures = False;
|
||||||
dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
|
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, xw.depth);
|
||||||
&gcvalues);
|
dc.gc = XCreateGC(xw.dpy, xw.buf, GCGraphicsExposures, &gcvalues);
|
||||||
xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
|
||||||
DefaultDepth(xw.dpy, xw.scr));
|
|
||||||
XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
|
XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
|
||||||
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
|
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
|
||||||
|
|
||||||
@@ -2093,6 +2110,9 @@ main(int argc, char *argv[])
|
|||||||
case 'a':
|
case 'a':
|
||||||
allowaltscreen = 0;
|
allowaltscreen = 0;
|
||||||
break;
|
break;
|
||||||
|
case 'A':
|
||||||
|
opt_alpha = EARGF(usage());
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
opt_class = EARGF(usage());
|
opt_class = EARGF(usage());
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user