Compare commits
149 Commits
0.8
...
patch-clic
Author | SHA1 | Date | |
---|---|---|---|
b1e6c91433 | |||
98610fcd37 | |||
6009e6e25b | |||
a0274bc20e | |||
5dbcca4926 | |||
d63b9eb902 | |||
497a756382 | |||
8c68ec5241 | |||
5ce9716281 | |||
f20e169a20 | |||
95f22c5305 | |||
7473a8d1a5 | |||
a3f7420310 | |||
9846a56bd7 | |||
559fdc2786 | |||
8abe4bcb41 | |||
2fc7e532b2 | |||
a6bbc0c96b | |||
eb3b894f40 | |||
3a6d6d7401 | |||
211964d56e | |||
f17abd25b3 | |||
7e8050cc62 | |||
e5e959835b | |||
68d1ad9b54 | |||
0008519903 | |||
72fd32736a | |||
baa9357e96 | |||
8629d9a1da | |||
ef0551932f | |||
af3bb68add | |||
2aefa348ba | |||
e823e2308f | |||
2c5edf28ec | |||
b1d97fec47 | |||
ea7cd7b62f | |||
7fb0c0cc68 | |||
7e1c68f25d | |||
65f1dc4283 | |||
a0467c802d | |||
273db5ceaf | |||
8e31030390 | |||
2f6e597ed8 | |||
1d3142da96 | |||
2ec571a30c | |||
4536f46cff | |||
9e68fdbcdb | |||
4ef0cbd8b9 | |||
28b4c822c5 | |||
fa253f077f | |||
b27a383a3a | |||
81067c65ea | |||
f74a9df6e1 | |||
818ec746f4 | |||
9ba7ecf7b1 | |||
a2a704492b | |||
0f8b40652b | |||
e6e2c6199f | |||
94b8ec0021 | |||
dec6b530a4 | |||
475a0a36cb | |||
e8392b282c | |||
f8afebdfa0 | |||
bda9c9ffa6 | |||
045a0fab4f | |||
9c30066e73 | |||
8304d4f059 | |||
914fb825df | |||
cde480c693 | |||
8211e36d28 | |||
87545c612e | |||
1d59091065 | |||
d6ea0a1a61 | |||
43a395ae91 | |||
72e3f6c7c0 | |||
33a9a45664 | |||
771bc401f7 | |||
d66bd405c0 | |||
e997303502 | |||
c1145268f6 | |||
0b73612c0d | |||
019449a7e6 | |||
fbae700a3f | |||
e52319cc7d | |||
21e0d6e8b8 | |||
5703aa0390 | |||
28ad288399 | |||
51e19ea11d | |||
26cdfebf31 | |||
cd785755f2 | |||
2cb539142b | |||
99de333951 | |||
895e5b50a8 | |||
384830110b | |||
2e54a21b5a | |||
289c52b7aa | |||
7ceb3d1f72 | |||
ea4d933ed9 | |||
83866428de | |||
1f09f0b0bb | |||
a2c479c4c8 | |||
d2b75db8d7 | |||
b6d280de6d | |||
ba7f4d69af | |||
2b8333f553 | |||
caa1d8fbea | |||
f1546cf9c1 | |||
21367a040f | |||
b650256044 | |||
9acec468fb | |||
927621f6da | |||
add0211522 | |||
d5efd256aa | |||
75b4ba4b4b | |||
ed68fe7dce | |||
4e0135afec | |||
a8cb8e9454 | |||
e85b6b6466 | |||
75f92eb348 | |||
3be4cf11d7 | |||
16d98738e7 | |||
e23acb9188 | |||
7e19e11676 | |||
096b125db7 | |||
d7bf023b2f | |||
b4d68d4daa | |||
30ec9a3dc3 | |||
67d0cb65d0 | |||
4f4bccd162 | |||
8ed7a4b3b7 | |||
732be223ee | |||
5535c1f04c | |||
b51bcd5553 | |||
1911c9274d | |||
29f341da7c | |||
dc3b5babf1 | |||
235a783e03 | |||
30ce2cc002 | |||
041912a791 | |||
bd3f7fd842 | |||
74cff67bd7 | |||
6f0f2b7ec3 | |||
f4020b2cc4 | |||
a5a928bfc1 | |||
6ac8c8aa50 | |||
5345db3c9b | |||
7648697f71 | |||
0b507bb731 | |||
e7ef3c4ce9 |
110
FAQ
110
FAQ
@ -1,6 +1,7 @@
|
||||
## Why does st not handle utmp entries?
|
||||
|
||||
Use the excellent tool of [utmp](http://git.suckless.org/utmp/) for this task.
|
||||
Use the excellent tool of [utmp](https://git.suckless.org/utmp/) for this task.
|
||||
|
||||
|
||||
## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
|
||||
|
||||
@ -8,6 +9,7 @@ It means that st doesn’t have any terminfo entry on your system. Chances are
|
||||
you did not `make install`. If you just want to test it without installing it,
|
||||
you can manually run `tic -sx st.info`.
|
||||
|
||||
|
||||
## Nothing works, and nothing is said about an unknown terminal!
|
||||
|
||||
* Some programs just assume they’re running in xterm i.e. they don’t rely on
|
||||
@ -15,19 +17,21 @@ you can manually run `tic -sx st.info`.
|
||||
* Some programs don’t complain about the lacking st description and default to
|
||||
another terminal. In that case see the question about terminfo.
|
||||
|
||||
## I get some weird glitches/visual bug on _random program_!
|
||||
|
||||
Try launching it with a different TERM: $ TERM=xterm myapp. toe(1) will give
|
||||
you a list of available terminals, but you’ll most likely switch between xterm,
|
||||
st or st-256color. The default value for TERM can be changed in config.h
|
||||
(TNAME).
|
||||
|
||||
## How do I scroll back up?
|
||||
|
||||
Using a terminal multiplexer.
|
||||
* Using a terminal multiplexer.
|
||||
* `st -e tmux` using C-b [
|
||||
* `st -e screen` using C-a ESC
|
||||
* Using the excellent tool of [scroll](https://git.suckless.org/scroll/).
|
||||
* Using the scrollback [patch](https://st.suckless.org/patches/scrollback/).
|
||||
|
||||
|
||||
## I would like to have utmp and/or scroll functionality by default
|
||||
|
||||
You can add the absolute path of both programs in your config.h file. You only
|
||||
have to modify the value of utmp and scroll variables.
|
||||
|
||||
* `st -e tmux` using C-b [
|
||||
* `st -e screen` using C-a ESC
|
||||
|
||||
## Why doesn't the Del key work in some programs?
|
||||
|
||||
@ -84,12 +88,14 @@ If you are using zsh, then read the zsh FAQ
|
||||
|
||||
Putting these lines into your .zshrc will fix the problems.
|
||||
|
||||
|
||||
## How can I use meta in 8bit mode?
|
||||
|
||||
St supports meta in 8bit mode, but the default terminfo entry doesn't
|
||||
use this capability. If you want it, you have to use the 'st-meta' value
|
||||
in TERM.
|
||||
|
||||
|
||||
## I cannot compile st in OpenBSD
|
||||
|
||||
OpenBSD lacks librt, despite it being mandatory in POSIX
|
||||
@ -98,13 +104,14 @@ If you want to compile st for OpenBSD you have to remove -lrt from config.mk, an
|
||||
st will compile without any loss of functionality, because all the functions are
|
||||
included in libc on this platform.
|
||||
|
||||
|
||||
## The Backspace Case
|
||||
|
||||
St is emulating the Linux way of handling backspace being delete and delete being
|
||||
backspace.
|
||||
|
||||
This is an issue that was discussed in suckless mailing list
|
||||
<http://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy
|
||||
<https://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy
|
||||
terminal users wants its backspace to be how he feels it:
|
||||
|
||||
Well, I am going to comment why I want to change the behaviour
|
||||
@ -159,9 +166,88 @@ terminal users wants its backspace to be how he feels it:
|
||||
[1] http://www.ibb.net/~anne/keyboard.html
|
||||
[2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html
|
||||
|
||||
|
||||
## But I really want the old grumpy behaviour of my terminal
|
||||
|
||||
Apply [1].
|
||||
|
||||
[1] http://st.suckless.org/patches/delkey
|
||||
[1] https://st.suckless.org/patches/delkey
|
||||
|
||||
|
||||
## Why do images not work in st using the w3m image hack?
|
||||
|
||||
w3mimg uses a hack that draws an image on top of the terminal emulator Drawable
|
||||
window. The hack relies on the terminal to use a single buffer to draw its
|
||||
contents directly.
|
||||
|
||||
st uses double-buffered drawing so the image is quickly replaced and may show a
|
||||
short flicker effect.
|
||||
|
||||
Below is a patch example to change st double-buffering to a single Drawable
|
||||
buffer.
|
||||
|
||||
diff --git a/x.c b/x.c
|
||||
--- a/x.c
|
||||
+++ b/x.c
|
||||
@@ -732,10 +732,6 @@ xresize(int col, int row)
|
||||
win.tw = col * win.cw;
|
||||
win.th = row * win.ch;
|
||||
|
||||
- XFreePixmap(xw.dpy, xw.buf);
|
||||
- xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
|
||||
- DefaultDepth(xw.dpy, xw.scr));
|
||||
- XftDrawChange(xw.draw, xw.buf);
|
||||
xclear(0, 0, win.w, win.h);
|
||||
|
||||
/* resize to new width */
|
||||
@@ -1148,8 +1144,7 @@ xinit(int cols, int rows)
|
||||
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 = xw.win;
|
||||
XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
|
||||
XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
|
||||
|
||||
@@ -1632,8 +1627,6 @@ xdrawline(Line line, int x1, int y1, int x2)
|
||||
void
|
||||
xfinishdraw(void)
|
||||
{
|
||||
- XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, win.w,
|
||||
- win.h, 0, 0);
|
||||
XSetForeground(xw.dpy, dc.gc,
|
||||
dc.col[IS_SET(MODE_REVERSE)?
|
||||
defaultfg : defaultbg].pixel);
|
||||
|
||||
|
||||
## BadLength X error in Xft when trying to render emoji
|
||||
|
||||
Xft makes st crash when rendering color emojis with the following error:
|
||||
|
||||
"X Error of failed request: BadLength (poly request too large or internal Xlib length error)"
|
||||
Major opcode of failed request: 139 (RENDER)
|
||||
Minor opcode of failed request: 20 (RenderAddGlyphs)
|
||||
Serial number of failed request: 1595
|
||||
Current serial number in output stream: 1818"
|
||||
|
||||
This is a known bug in Xft (not st) which happens on some platforms and
|
||||
combination of particular fonts and fontconfig settings.
|
||||
|
||||
See also:
|
||||
https://gitlab.freedesktop.org/xorg/lib/libxft/issues/6
|
||||
https://bugs.freedesktop.org/show_bug.cgi?id=107534
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1498269
|
||||
|
||||
The solution is to remove color emoji fonts or disable this in the fontconfig
|
||||
XML configuration. As an ugly workaround (which may work only on newer
|
||||
fontconfig versions (FC_COLOR)), the following code can be used to mask color
|
||||
fonts:
|
||||
|
||||
FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
|
||||
|
||||
Please don't bother reporting this bug to st, but notify the upstream Xft
|
||||
developers about fixing this bug.
|
||||
|
||||
As of 2022-09-05 this now seems to be finally fixed in libXft 2.3.5:
|
||||
https://gitlab.freedesktop.org/xorg/lib/libxft/-/blob/libXft-2.3.5/NEWS
|
||||
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT/X Consortium License
|
||||
|
||||
© 2014-2018 Hiltjo Posthuma <hiltjo at codemadness dot org>
|
||||
© 2014-2022 Hiltjo Posthuma <hiltjo at codemadness dot org>
|
||||
© 2018 Devin J. Pohly <djpohly at gmail dot com>
|
||||
© 2014-2017 Quentin Rameau <quinq at fifth dot space>
|
||||
© 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com>
|
||||
|
12
Makefile
12
Makefile
@ -7,13 +7,7 @@ include config.mk
|
||||
SRC = st.c x.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
all: options st
|
||||
|
||||
options:
|
||||
@echo st build options:
|
||||
@echo "CFLAGS = $(STCFLAGS)"
|
||||
@echo "LDFLAGS = $(STLDFLAGS)"
|
||||
@echo "CC = $(CC)"
|
||||
all: st
|
||||
|
||||
config.h:
|
||||
cp config.def.h config.h
|
||||
@ -22,7 +16,7 @@ config.h:
|
||||
$(CC) $(STCFLAGS) -c $<
|
||||
|
||||
st.o: config.h st.h win.h
|
||||
x.o: arg.h st.h win.h
|
||||
x.o: arg.h config.h st.h win.h
|
||||
|
||||
$(OBJ): config.h config.mk
|
||||
|
||||
@ -54,4 +48,4 @@ uninstall:
|
||||
rm -f $(DESTDIR)$(PREFIX)/bin/st
|
||||
rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
|
||||
|
||||
.PHONY: all options clean dist install uninstall
|
||||
.PHONY: all clean dist install uninstall
|
||||
|
22
arg.h
22
arg.h
@ -21,28 +21,30 @@ extern char *argv0;
|
||||
argc--;\
|
||||
break;\
|
||||
}\
|
||||
for (brk_ = 0, argv[0]++, argv_ = argv;\
|
||||
argv[0][0] && !brk_;\
|
||||
argv[0]++) {\
|
||||
int i_;\
|
||||
for (i_ = 1, brk_ = 0, argv_ = argv;\
|
||||
argv[0][i_] && !brk_;\
|
||||
i_++) {\
|
||||
if (argv_ != argv)\
|
||||
break;\
|
||||
argc_ = argv[0][0];\
|
||||
argc_ = argv[0][i_];\
|
||||
switch (argc_)
|
||||
|
||||
#define ARGEND }\
|
||||
}
|
||||
|
||||
#define ARGC() argc_
|
||||
|
||||
#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
||||
#define EARGF(x) ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
|
||||
((x), abort(), (char *)0) :\
|
||||
(brk_ = 1, (argv[0][1] != '\0')?\
|
||||
(&argv[0][1]) :\
|
||||
(brk_ = 1, (argv[0][i_+1] != '\0')?\
|
||||
(&argv[0][i_+1]) :\
|
||||
(argc--, argv++, argv[0])))
|
||||
|
||||
#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
||||
#define ARGF() ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
|
||||
(char *)0 :\
|
||||
(brk_ = 1, (argv[0][1] != '\0')?\
|
||||
(&argv[0][1]) :\
|
||||
(brk_ = 1, (argv[0][i_+1] != '\0')?\
|
||||
(&argv[0][i_+1]) :\
|
||||
(argc--, argv++, argv[0])))
|
||||
|
||||
#endif
|
||||
|
71
config.def.h
71
config.def.h
@ -11,13 +11,15 @@ static int borderpx = 2;
|
||||
/*
|
||||
* What program is execed by st depends of these precedence rules:
|
||||
* 1: program passed with -e
|
||||
* 2: utmp option
|
||||
* 2: scroll and/or utmp
|
||||
* 3: SHELL environment variable
|
||||
* 4: value of shell in /etc/passwd
|
||||
* 5: value of shell in config.h
|
||||
*/
|
||||
static char *shell = "/bin/sh";
|
||||
char *utmp = NULL;
|
||||
/* scroll program: to enable use a string like "scroll" */
|
||||
char *scroll = NULL;
|
||||
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
|
||||
|
||||
/* identification sequence returned in DA and DECID */
|
||||
@ -30,9 +32,9 @@ static float chscale = 1.0;
|
||||
/*
|
||||
* word delimiter string
|
||||
*
|
||||
* More advanced example: " `'\"()[]{}"
|
||||
* More advanced example: L" `'\"()[]{}"
|
||||
*/
|
||||
char *worddelimiters = " ";
|
||||
wchar_t *worddelimiters = L" ";
|
||||
|
||||
/* selection timeouts (in milliseconds) */
|
||||
static unsigned int doubleclicktimeout = 300;
|
||||
@ -41,9 +43,18 @@ static unsigned int tripleclicktimeout = 600;
|
||||
/* alt screens */
|
||||
int allowaltscreen = 1;
|
||||
|
||||
/* frames per second st should at maximum draw to the screen */
|
||||
static unsigned int xfps = 120;
|
||||
static unsigned int actionfps = 30;
|
||||
/* allow certain non-interactive (insecure) window operations such as:
|
||||
setting the clipboard text */
|
||||
int allowwindowops = 0;
|
||||
|
||||
/*
|
||||
* draw latency range in ms - from new content/keypress/etc until drawing.
|
||||
* within this range, st draws when content stops arriving (idle). mostly it's
|
||||
* near minlatency, but it waits longer for slow updates to avoid partial draw.
|
||||
* low minlatency will tear/flicker more, as it can "detect" idle too early.
|
||||
*/
|
||||
static double minlatency = 2;
|
||||
static double maxlatency = 33;
|
||||
|
||||
/*
|
||||
* blinking timeout (set to 0 to disable blinking) for the terminal blinking
|
||||
@ -109,6 +120,8 @@ static const char *colorname[] = {
|
||||
/* more colors can be added after 255 to use with DefaultXX */
|
||||
"#cccccc",
|
||||
"#555555",
|
||||
"gray90", /* default foreground colour */
|
||||
"black", /* default background colour */
|
||||
};
|
||||
|
||||
|
||||
@ -116,9 +129,9 @@ static const char *colorname[] = {
|
||||
* Default colors (colorname index)
|
||||
* foreground, background, cursor, reverse cursor
|
||||
*/
|
||||
unsigned int defaultfg = 7;
|
||||
unsigned int defaultbg = 0;
|
||||
static unsigned int defaultcs = 256;
|
||||
unsigned int defaultfg = 258;
|
||||
unsigned int defaultbg = 259;
|
||||
unsigned int defaultcs = 256;
|
||||
static unsigned int defaultrcs = 257;
|
||||
|
||||
/*
|
||||
@ -150,14 +163,24 @@ static unsigned int mousebg = 0;
|
||||
*/
|
||||
static unsigned int defaultattr = 11;
|
||||
|
||||
/*
|
||||
* Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
|
||||
* Note that if you want to use ShiftMask with selmasks, set this to an other
|
||||
* modifier, set to 0 to not use it.
|
||||
*/
|
||||
static uint forcemousemod = ShiftMask;
|
||||
|
||||
/*
|
||||
* Internal mouse shortcuts.
|
||||
* Beware that overloading Button1 will disable the selection.
|
||||
*/
|
||||
static MouseShortcut mshortcuts[] = {
|
||||
/* button mask string */
|
||||
{ Button4, XK_ANY_MOD, "\031" },
|
||||
{ Button5, XK_ANY_MOD, "\005" },
|
||||
/* mask button function argument release */
|
||||
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
|
||||
{ ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
|
||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
||||
{ ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
|
||||
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
||||
};
|
||||
|
||||
/* Internal keyboard shortcuts. */
|
||||
@ -176,8 +199,8 @@ static Shortcut shortcuts[] = {
|
||||
{ TERMMOD, XK_C, clipcopy, {.i = 0} },
|
||||
{ TERMMOD, XK_V, clippaste, {.i = 0} },
|
||||
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
|
||||
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
|
||||
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
||||
{ TERMMOD, XK_I, iso14755, {.i = 0} },
|
||||
};
|
||||
|
||||
/*
|
||||
@ -195,10 +218,6 @@ static Shortcut shortcuts[] = {
|
||||
* * 0: no value
|
||||
* * > 0: cursor application mode enabled
|
||||
* * < 0: cursor application mode disabled
|
||||
* crlf value
|
||||
* * 0: no value
|
||||
* * > 0: crlf mode is enabled
|
||||
* * < 0: crlf mode is disabled
|
||||
*
|
||||
* Be careful with the order of the definitions because st searches in
|
||||
* this table sequentially, so any XK_ANY_MOD must be in the last
|
||||
@ -217,13 +236,6 @@ static KeySym mappedkeys[] = { -1 };
|
||||
*/
|
||||
static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
|
||||
|
||||
/*
|
||||
* Override mouse-select while mask is active (when MODE_MOUSE is set).
|
||||
* Note that if you want to use ShiftMask with selmasks, set this to an other
|
||||
* modifier, set to 0 to not use it.
|
||||
*/
|
||||
static uint forceselmod = ShiftMask;
|
||||
|
||||
/*
|
||||
* This is the huge key array which defines all compatibility to the Linux
|
||||
* world. Please decide about changes wisely.
|
||||
@ -460,3 +472,14 @@ static char ascii_printable[] =
|
||||
" !\"#$%&'()*+,-./0123456789:;<=>?"
|
||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
||||
"`abcdefghijklmnopqrstuvwxyz{|}~";
|
||||
|
||||
/*
|
||||
* Open urls starting with urlprefixes, contatining urlchars
|
||||
* by passing as ARG1 to urlhandler.
|
||||
*/
|
||||
char* urlhandler = "xdg-open";
|
||||
char urlchars[] =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789-._~:/?#@!$&'*+,;=%";
|
||||
char* urlprefixes[] = {"http://", "https://", NULL};
|
||||
|
24
config.mk
24
config.mk
@ -1,5 +1,5 @@
|
||||
# st version
|
||||
VERSION = 0.8
|
||||
VERSION = 0.9.2
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
@ -10,19 +10,27 @@ MANPREFIX = $(PREFIX)/share/man
|
||||
X11INC = /usr/X11R6/include
|
||||
X11LIB = /usr/X11R6/lib
|
||||
|
||||
PKG_CONFIG = pkg-config
|
||||
|
||||
# includes and libs
|
||||
INCS = -I$(X11INC) \
|
||||
`pkg-config --cflags fontconfig` \
|
||||
`pkg-config --cflags freetype2`
|
||||
`$(PKG_CONFIG) --cflags fontconfig` \
|
||||
`$(PKG_CONFIG) --cflags freetype2`
|
||||
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
|
||||
`pkg-config --libs fontconfig` \
|
||||
`pkg-config --libs freetype2`
|
||||
`$(PKG_CONFIG) --libs fontconfig` \
|
||||
`$(PKG_CONFIG) --libs freetype2`
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
|
||||
STCFLAGS = $(INCS) $(CPPFLAGS) $(CFLAGS)
|
||||
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
|
||||
STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
|
||||
STLDFLAGS = $(LIBS) $(LDFLAGS)
|
||||
|
||||
# OpenBSD:
|
||||
#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
|
||||
#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
|
||||
# `$(PKG_CONFIG) --libs fontconfig` \
|
||||
# `$(PKG_CONFIG) --libs freetype2`
|
||||
#MANPREFIX = ${PREFIX}/man
|
||||
|
||||
# compiler and linker
|
||||
# CC = c99
|
||||
|
||||
|
192
patches/st-clickurl-0.8.5.diff
Normal file
192
patches/st-clickurl-0.8.5.diff
Normal file
@ -0,0 +1,192 @@
|
||||
From d5b492049f48dc411b0dd7dc01a403304c20438d Mon Sep 17 00:00:00 2001
|
||||
From: Jishnu Sen <jishnu1@gmail.com>
|
||||
Date: Sun, 7 Apr 2024 22:54:46 -0700
|
||||
Subject: [PATCH] Highlight URLs with control and follow with click
|
||||
|
||||
---
|
||||
config.def.h | 11 +++++++
|
||||
st.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
st.h | 9 ++++++
|
||||
x.c | 24 +++++++++++++-
|
||||
4 files changed, 132 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 91ab8ca..4961830 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -472,3 +472,14 @@ static char ascii_printable[] =
|
||||
" !\"#$%&'()*+,-./0123456789:;<=>?"
|
||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
||||
"`abcdefghijklmnopqrstuvwxyz{|}~";
|
||||
+
|
||||
+/*
|
||||
+ * Open urls starting with urlprefixes, contatining urlchars
|
||||
+ * by passing as ARG1 to urlhandler.
|
||||
+ */
|
||||
+char* urlhandler = "xdg-open";
|
||||
+char urlchars[] =
|
||||
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
+ "abcdefghijklmnopqrstuvwxyz"
|
||||
+ "0123456789-._~:/?#@!$&'*+,;=%";
|
||||
+char* urlprefixes[] = {"http://", "https://", NULL};
|
||||
diff --git a/st.c b/st.c
|
||||
index 51049ba..8f2156c 100644
|
||||
--- a/st.c
|
||||
+++ b/st.c
|
||||
@@ -643,6 +643,95 @@ getsel(void)
|
||||
return str;
|
||||
}
|
||||
|
||||
+char *
|
||||
+strstrany(char* s, char** strs) {
|
||||
+ char *match;
|
||||
+ for (int i = 0; strs[i]; i++) {
|
||||
+ if ((match = strstr(s, strs[i]))) {
|
||||
+ return match;
|
||||
+ }
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+highlighturls(void)
|
||||
+{
|
||||
+ char *match;
|
||||
+ char *linestr = calloc(sizeof(char), term.col+1); /* assume ascii */
|
||||
+ for (int i = term.top; i < term.bot; i++) {
|
||||
+ int url_start = -1;
|
||||
+ for (int j = 0; j < term.col; j++) {
|
||||
+ if (term.line[i][j].u < 127) {
|
||||
+ linestr[j] = term.line[i][j].u;
|
||||
+ }
|
||||
+ linestr[term.col] = '\0';
|
||||
+ }
|
||||
+ while ((match = strstrany(linestr + url_start + 1, urlprefixes))) {
|
||||
+ url_start = match - linestr;
|
||||
+ for (int c = url_start; c < term.col && strchr(urlchars, linestr[c]); c++) {
|
||||
+ term.line[i][c].mode |= ATTR_URL;
|
||||
+ tsetdirt(i, c);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ free(linestr);
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+unhighlighturls(void)
|
||||
+{
|
||||
+ for (int i = term.top; i < term.bot; i++) {
|
||||
+ for (int j = 0; j < term.col; j++) {
|
||||
+ Glyph* g = &term.line[i][j];
|
||||
+ if (g->mode & ATTR_URL) {
|
||||
+ g->mode &= ~ATTR_URL;
|
||||
+ tsetdirt(i, j);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+followurl(int x, int y) {
|
||||
+ char *linestr = calloc(sizeof(char), term.col+1); /* assume ascii */
|
||||
+ char *match;
|
||||
+ for (int i = 0; i < term.col; i++) {
|
||||
+ if (term.line[x][i].u < 127) {
|
||||
+ linestr[i] = term.line[x][i].u;
|
||||
+ }
|
||||
+ linestr[term.col] = '\0';
|
||||
+ }
|
||||
+ int url_start = -1;
|
||||
+ while ((match = strstrany(linestr + url_start + 1, urlprefixes))) {
|
||||
+ url_start = match - linestr;
|
||||
+ int url_end = url_start;
|
||||
+ for (int c = url_start; c < term.col && strchr(urlchars, linestr[c]); c++) {
|
||||
+ url_end++;
|
||||
+ }
|
||||
+ if (url_start <= y && y < url_end) {
|
||||
+ linestr[url_end] = '\0';
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if (url_start == -1) {
|
||||
+ free(linestr);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ pid_t chpid;
|
||||
+ if ((chpid = fork()) == 0) {
|
||||
+ if (fork() == 0)
|
||||
+ execlp(urlhandler, urlhandler, linestr + url_start, NULL);
|
||||
+ exit(1);
|
||||
+ }
|
||||
+ if (chpid > 0)
|
||||
+ waitpid(chpid, NULL, 0);
|
||||
+ free(linestr);
|
||||
+ unhighlighturls();
|
||||
+}
|
||||
+
|
||||
void
|
||||
selclear(void)
|
||||
{
|
||||
diff --git a/st.h b/st.h
|
||||
index 519b9bd..354e7f9 100644
|
||||
--- a/st.h
|
||||
+++ b/st.h
|
||||
@@ -34,6 +34,7 @@ enum glyph_attribute {
|
||||
ATTR_WIDE = 1 << 9,
|
||||
ATTR_WDUMMY = 1 << 10,
|
||||
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
||||
+ ATTR_URL = 1 << 14,
|
||||
};
|
||||
|
||||
enum selection_mode {
|
||||
@@ -105,6 +106,10 @@ void selextend(int, int, int, int);
|
||||
int selected(int, int);
|
||||
char *getsel(void);
|
||||
|
||||
+void highlighturls(void);
|
||||
+void unhighlighturls(void);
|
||||
+void followurl(int, int);
|
||||
+
|
||||
size_t utf8encode(Rune, char *);
|
||||
|
||||
void *xmalloc(size_t);
|
||||
@@ -126,3 +131,7 @@ extern unsigned int tabspaces;
|
||||
extern unsigned int defaultfg;
|
||||
extern unsigned int defaultbg;
|
||||
extern unsigned int defaultcs;
|
||||
+extern char *urlhandler;
|
||||
+extern char urlchars[];
|
||||
+extern char *urlprefixes[];
|
||||
+extern int nurlprefixes;
|
||||
diff --git a/x.c b/x.c
|
||||
index 8a16faa..13f68e4 100644
|
||||
--- a/x.c
|
||||
+++ b/x.c
|
||||
@@ -191,6 +191,7 @@ static void usage(void);
|
||||
|
||||
static void (*handler[LASTEvent])(XEvent *) = {
|
||||
[KeyPress] = kpress,
|
||||
+ [KeyRelease] = kpress,
|
||||
[ClientMessage] = cmessage,
|
||||
[ConfigureNotify] = resize,
|
||||
[VisibilityNotify] = visibility,
|
||||
@@ -445,6 +446,15 @@ mouseaction(XEvent *e, uint release)
|
||||
/* ignore Button<N>mask for Button<N> - it's set on release */
|
||||
uint state = e->xbutton.state & ~buttonmask(e->xbutton.button);
|
||||
|
||||
+ if (release == 0 &&
|
||||
+ e->xbutton.button == Button1 &&
|
||||
+ (match(ControlMask, state) ||
|
||||
+ match(ControlMask, state & ~forcemousemod))) {
|
||||
+ followurl(evrow(e), evcol(e));
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
|
||||
if (ms->release == release &&
|
||||
ms->button == e->xbutton.button &&
|
||||
2.44.0
|
||||
|
7
st.1
7
st.1
@ -159,10 +159,6 @@ Copy the selected text to the clipboard selection.
|
||||
.TP
|
||||
.B Ctrl-Shift-v
|
||||
Paste from the clipboard selection.
|
||||
.TP
|
||||
.B Ctrl-Shift-i
|
||||
Launch dmenu to enter a unicode codepoint and send the corresponding glyph
|
||||
to st.
|
||||
.SH CUSTOMIZATION
|
||||
.B st
|
||||
can be customized by creating a custom config.h and (re)compiling the source
|
||||
@ -174,7 +170,8 @@ See the LICENSE file for the terms of redistribution.
|
||||
.SH SEE ALSO
|
||||
.BR tabbed (1),
|
||||
.BR utmp (1),
|
||||
.BR stty (1)
|
||||
.BR stty (1),
|
||||
.BR scroll (1)
|
||||
.SH BUGS
|
||||
See the TODO file in the distribution.
|
||||
|
||||
|
20
st.h
20
st.h
@ -34,6 +34,7 @@ enum glyph_attribute {
|
||||
ATTR_WIDE = 1 << 9,
|
||||
ATTR_WDUMMY = 1 << 10,
|
||||
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
||||
ATTR_URL = 1 << 14,
|
||||
};
|
||||
|
||||
enum selection_mode {
|
||||
@ -74,13 +75,13 @@ typedef union {
|
||||
uint ui;
|
||||
float f;
|
||||
const void *v;
|
||||
const char *s;
|
||||
} Arg;
|
||||
|
||||
void die(const char *, ...);
|
||||
void redraw(void);
|
||||
void draw(void);
|
||||
|
||||
void iso14755(const Arg *);
|
||||
void printscreen(const Arg *);
|
||||
void printsel(const Arg *);
|
||||
void sendbreak(const Arg *);
|
||||
@ -91,7 +92,7 @@ void tnew(int, int);
|
||||
void tresize(int, int);
|
||||
void tsetdirtattr(int);
|
||||
void ttyhangup(void);
|
||||
int ttynew(char *, char *, char *, char **);
|
||||
int ttynew(const char *, char *, const char *, char **);
|
||||
size_t ttyread(void);
|
||||
void ttyresize(int, int);
|
||||
void ttywrite(const char *, size_t, int);
|
||||
@ -105,19 +106,30 @@ void selextend(int, int, int, int);
|
||||
int selected(int, int);
|
||||
char *getsel(void);
|
||||
|
||||
void highlighturls(void);
|
||||
void unhighlighturls(void);
|
||||
void followurl(int, int);
|
||||
|
||||
size_t utf8encode(Rune, char *);
|
||||
|
||||
void *xmalloc(size_t);
|
||||
void *xrealloc(void *, size_t);
|
||||
char *xstrdup(char *);
|
||||
char *xstrdup(const char *);
|
||||
|
||||
/* config.h globals */
|
||||
extern char *utmp;
|
||||
extern char *scroll;
|
||||
extern char *stty_args;
|
||||
extern char *vtiden;
|
||||
extern char *worddelimiters;
|
||||
extern wchar_t *worddelimiters;
|
||||
extern int allowaltscreen;
|
||||
extern int allowwindowops;
|
||||
extern char *termname;
|
||||
extern unsigned int tabspaces;
|
||||
extern unsigned int defaultfg;
|
||||
extern unsigned int defaultbg;
|
||||
extern unsigned int defaultcs;
|
||||
extern char *urlhandler;
|
||||
extern char urlchars[];
|
||||
extern char *urlprefixes[];
|
||||
extern int nurlprefixes;
|
||||
|
41
st.info
41
st.info
@ -1,4 +1,4 @@
|
||||
st| simpleterm,
|
||||
st-mono| simpleterm monocolor,
|
||||
acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
|
||||
am,
|
||||
bce,
|
||||
@ -10,7 +10,7 @@ st| simpleterm,
|
||||
civis=\E[?25l,
|
||||
clear=\E[H\E[2J,
|
||||
cnorm=\E[?12l\E[?25h,
|
||||
colors#8,
|
||||
colors#2,
|
||||
cols#80,
|
||||
cr=^M,
|
||||
csr=\E[%i%p1%d;%p2%dr,
|
||||
@ -158,6 +158,7 @@ st| simpleterm,
|
||||
rc=\E8,
|
||||
rev=\E[7m,
|
||||
ri=\EM,
|
||||
rin=\E[%p1%dT,
|
||||
ritm=\E[23m,
|
||||
rmacs=\E(B,
|
||||
rmcup=\E[?1049l,
|
||||
@ -168,13 +169,8 @@ st| simpleterm,
|
||||
rs1=\Ec,
|
||||
rs2=\E[4l\E>\E[?1034l,
|
||||
sc=\E7,
|
||||
setab=\E[4%p1%dm,
|
||||
setaf=\E[3%p1%dm,
|
||||
setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
|
||||
setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
|
||||
sgr0=\E[0m,
|
||||
sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
|
||||
sitm=\E[3m,
|
||||
sgr0=\E[0m,
|
||||
smacs=\E(0,
|
||||
smcup=\E[?1049h,
|
||||
smir=\E[4h,
|
||||
@ -188,11 +184,26 @@ st| simpleterm,
|
||||
# XTerm extensions
|
||||
rmxx=\E[29m,
|
||||
smxx=\E[9m,
|
||||
BE=\E[?2004h,
|
||||
BD=\E[?2004l,
|
||||
PS=\E[200~,
|
||||
PE=\E[201~,
|
||||
# disabled rep for now: causes some issues with older ncurses versions.
|
||||
# rep=%p1%c\E[%p2%{1}%-%db,
|
||||
# tmux extensions, see TERMINFO EXTENSIONS in tmux(1)
|
||||
Se,
|
||||
Ss,
|
||||
Tc,
|
||||
Ms=\E]52;%p1%s;%p2%s\007,
|
||||
Se=\E[2 q,
|
||||
Ss=\E[%p1%d q,
|
||||
|
||||
st| simpleterm,
|
||||
use=st-mono,
|
||||
colors#8,
|
||||
setab=\E[4%p1%dm,
|
||||
setaf=\E[3%p1%dm,
|
||||
setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
|
||||
setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
|
||||
sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
|
||||
|
||||
st-256color| simpleterm with 256 colors,
|
||||
use=st,
|
||||
@ -220,3 +231,13 @@ st-meta-256color| simpleterm with meta key and 256 colors,
|
||||
smm=\E[?1034h,
|
||||
rs2=\E[4l\E>\E[?1034h,
|
||||
is2=\E[4l\E>\E[?1034h,
|
||||
|
||||
st-bs| simpleterm with backspace as backspace,
|
||||
use=st,
|
||||
kbs=\010,
|
||||
kdch1=\177,
|
||||
|
||||
st-bs-256color| simpleterm with backspace as backspace and 256colors,
|
||||
use=st-256color,
|
||||
kbs=\010,
|
||||
kdch1=\177,
|
||||
|
3
win.h
3
win.h
@ -30,9 +30,12 @@ void xdrawline(Line, int, int, int);
|
||||
void xfinishdraw(void);
|
||||
void xloadcols(void);
|
||||
int xsetcolorname(int, const char *);
|
||||
int xgetcolor(int, unsigned char *, unsigned char *, unsigned char *);
|
||||
void xseticontitle(char *);
|
||||
void xsettitle(char *);
|
||||
int xsetcursor(int);
|
||||
void xsetmode(int, unsigned int);
|
||||
void xsetpointermotion(int);
|
||||
void xsetsel(char *);
|
||||
int xstartdraw(void);
|
||||
void xximspot(int, int);
|
||||
|
Reference in New Issue
Block a user