summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--dmenu/config.h23
-rw-r--r--dmenu/patches/dmenu-center-4.8.diff56
-rw-r--r--dwm/config.h115
-rw-r--r--slock/config.h24
-rw-r--r--slock/patches/slock-dpms-1.4.diff62
-rw-r--r--slock/patches/slock-message-20191002-b46028b.diff250
-rw-r--r--st/config.h473
-rw-r--r--st/patches/st-copyurl-20190202-0.8.1.diff109
-rw-r--r--st/patches/st-hidecursor-0.8.1.diff88
-rw-r--r--st/patches/st-scrollback-20200419-72e3f6c.diff351
-rw-r--r--st/patches/st-scrollback-mouse-20191024-a2c479c.diff13
-rw-r--r--st/patches/st-scrollback-mouse-altscreen-20200416-5703aa0.diff63
-rw-r--r--st/patches/st-vertcenter-20180320-6ac8c8a.diff51
14 files changed, 1679 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..dc66b82
--- /dev/null
+++ b/README.md
@@ -0,0 +1 @@
# suckless
diff --git a/dmenu/config.h b/dmenu/config.h
new file mode 100644
index 0000000..091780e
--- /dev/null
+++ b/dmenu/config.h
@@ -0,0 +1,23 @@
1/* See LICENSE file for copyright and license details. */
2/* Default settings; can be overriden by command line. */
3
4static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
5/* -fn option overrides fonts[0]; default X11 font or font set */
6static const char *fonts[] = {
7 "Hermit:size=10"
8};
9static const char *prompt = NULL; /* -p option; prompt to the left of input field */
10static const char *colors[SchemeLast][2] = {
11 /* fg bg */
12 [SchemeNorm] = { "#bbbbbb", "#222222" },
13 [SchemeSel] = { "#eeeeee", "#005577" },
14 [SchemeOut] = { "#000000", "#00ffff" },
15};
16/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
17static unsigned int lines = 0;
18
19/*
20 * Characters not considered part of a word while deleting words
21 * for example: " /?\"&[]"
22 */
23static const char worddelimiters[] = " ";
diff --git a/dmenu/patches/dmenu-center-4.8.diff b/dmenu/patches/dmenu-center-4.8.diff
new file mode 100644
index 0000000..a970fcb
--- /dev/null
+++ b/dmenu/patches/dmenu-center-4.8.diff
@@ -0,0 +1,56 @@
1diff --git a/dmenu.c b/dmenu.c
2index 5e9c367..2268ea9 100644
3--- a/dmenu.c
4+++ b/dmenu.c
5@@ -88,6 +88,15 @@ calcoffsets(void)
6 break;
7 }
8
9+static int
10+max_textw(void)
11+{
12+ int len = 0;
13+ for (struct item *item = items; item && item->text; item++)
14+ len = MAX(TEXTW(item->text), len);
15+ return len;
16+}
17+
18 static void
19 cleanup(void)
20 {
21@@ -598,6 +607,7 @@ setup(void)
22 bh = drw->fonts->h + 2;
23 lines = MAX(lines, 0);
24 mh = (lines + 1) * bh;
25+ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
26 #ifdef XINERAMA
27 i = 0;
28 if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
29@@ -624,9 +634,9 @@ setup(void)
30 if (INTERSECT(x, y, 1, 1, info[i]))
31 break;
32
33- x = info[i].x_org;
34- y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
35- mw = info[i].width;
36+ mw = MIN(MAX(max_textw() + promptw, 100), info[i].width);
37+ x = info[i].x_org + ((info[i].width - mw) / 2);
38+ y = info[i].y_org + ((info[i].height - mh) / 2);
39 XFree(info);
40 } else
41 #endif
42@@ -634,11 +644,10 @@ setup(void)
43 if (!XGetWindowAttributes(dpy, parentwin, &wa))
44 die("could not get embedding window attributes: 0x%lx",
45 parentwin);
46- x = 0;
47- y = topbar ? 0 : wa.height - mh;
48- mw = wa.width;
49+ mw = MIN(MAX(max_textw() + promptw, 100), wa.width);
50+ x = (wa.width - mw) / 2;
51+ y = (wa.height - mh) / 2;
52 }
53- promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
54 inputw = MIN(inputw, mw/3);
55 match();
56
diff --git a/dwm/config.h b/dwm/config.h
new file mode 100644
index 0000000..ccaface
--- /dev/null
+++ b/dwm/config.h
@@ -0,0 +1,115 @@
1/* See LICENSE file for copyright and license details. */
2
3/* appearance */
4static const unsigned int borderpx = 1; /* border pixel of windows */
5static const unsigned int snap = 32; /* snap pixel */
6static const int showbar = 1; /* 0 means no bar */
7static const int topbar = 1; /* 0 means bottom bar */
8static const char *fonts[] = { "Hermit:pixelsize=12:antialias:true:autohint=true" };
9static const char dmenufont[] = "Hermit:pixelsize=12:antialias:true:autohint=true";
10static const char col_gray1[] = "#222222";
11static const char col_gray2[] = "#444444";
12static const char col_gray3[] = "#bbbbbb";
13static const char col_gray4[] = "#eeeeee";
14static const char col_cyan[] = "#005577";
15static const char *colors[][3] = {
16 /* fg bg border */
17 [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
18 [SchemeSel] = { col_gray4, col_cyan, col_cyan },
19};
20
21/* tagging */
22static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
23
24static const Rule rules[] = {
25 /* xprop(1):
26 * WM_CLASS(STRING) = instance, class
27 * WM_NAME(STRING) = title
28 */
29 /* class instance title tags mask isfloating monitor */
30 { "Gimp", NULL, NULL, 0, 1, -1 },
31 { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
32};
33
34/* layout(s) */
35static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
36static const int nmaster = 1; /* number of clients in master area */
37static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
38
39static const Layout layouts[] = {
40 /* symbol arrange function */
41 { "[]=", tile }, /* first entry is default */
42 { "><>", NULL }, /* no layout function means floating behavior */
43 { "[M]", monocle },
44};
45
46/* key definitions */
47#define MODKEY Mod4Mask
48#define TAGKEYS(KEY,TAG) \
49 { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
50 { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
51 { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
52 { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
53
54/* helper for spawning shell commands in the pre dwm-5.0 fashion */
55#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
56
57/* commands */
58static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
59static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
60static const char *termcmd[] = { "st", NULL };
61
62static Key keys[] = {
63 /* modifier key function argument */
64 { MODKEY, XK_p, spawn, {.v = dmenucmd } },
65 { MODKEY, XK_Return, spawn, {.v = termcmd } },
66 { MODKEY, XK_b, togglebar, {0} },
67 { MODKEY, XK_j, focusstack, {.i = +1 } },
68 { MODKEY, XK_k, focusstack, {.i = -1 } },
69 { MODKEY, XK_i, incnmaster, {.i = +1 } },
70 { MODKEY, XK_d, incnmaster, {.i = -1 } },
71 { MODKEY, XK_h, setmfact, {.f = -0.05} },
72 { MODKEY, XK_l, setmfact, {.f = +0.05} },
73 { MODKEY, XK_Return, zoom, {0} },
74 { MODKEY, XK_Tab, view, {0} },
75 { MODKEY, XK_w, killclient, {0} },
76 { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
77 { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
78 { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
79 { MODKEY, XK_space, setlayout, {0} },
80 { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
81 { MODKEY, XK_0, view, {.ui = ~0 } },
82 { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
83 { MODKEY, XK_comma, focusmon, {.i = -1 } },
84 { MODKEY, XK_period, focusmon, {.i = +1 } },
85 { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
86 { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
87 TAGKEYS( XK_1, 0)
88 TAGKEYS( XK_2, 1)
89 TAGKEYS( XK_3, 2)
90 TAGKEYS( XK_4, 3)
91 TAGKEYS( XK_5, 4)
92 TAGKEYS( XK_6, 5)
93 TAGKEYS( XK_7, 6)
94 TAGKEYS( XK_8, 7)
95 TAGKEYS( XK_9, 8)
96 { MODKEY|ShiftMask, XK_q, quit, {0} },
97};
98
99/* button definitions */
100/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
101static Button buttons[] = {
102 /* click event mask button function argument */
103 { ClkLtSymbol, 0, Button1, setlayout, {0} },
104 { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
105 { ClkWinTitle, 0, Button2, zoom, {0} },
106 { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
107 { ClkClientWin, MODKEY, Button1, movemouse, {0} },
108 { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
109 { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
110 { ClkTagBar, 0, Button1, view, {0} },
111 { ClkTagBar, 0, Button3, toggleview, {0} },
112 { ClkTagBar, MODKEY, Button1, tag, {0} },
113 { ClkTagBar, MODKEY, Button3, toggletag, {0} },
114};
115
diff --git a/slock/config.h b/slock/config.h
new file mode 100644
index 0000000..6f12b0d
--- /dev/null
+++ b/slock/config.h
@@ -0,0 +1,24 @@
1/* user and group to drop privileges to */
2static const char *user = "nobody";
3static const char *group = "nogroup";
4
5static const char *colorname[NUMCOLS] = {
6 [INIT] = "black", /* after initialization */
7 [INPUT] = "black", /* during input */
8 [FAILED] = "#CC3333", /* wrong password */
9};
10
11/* treat a cleared input like a wrong password (color) */
12static const int failonclear = 1;
13
14/* default message */
15static const char * message = "Locked";
16
17/* text color */
18static const char * text_color = "#a8fffe";
19
20/* text size (must be a valid size) */
21static const char * font_name = "fixed";
22
23/* time in seconds before the monitor shuts down */
24static const int monitortime = 5;
diff --git a/slock/patches/slock-dpms-1.4.diff b/slock/patches/slock-dpms-1.4.diff
new file mode 100644
index 0000000..027bbf7
--- /dev/null
+++ b/slock/patches/slock-dpms-1.4.diff
@@ -0,0 +1,62 @@
1diff --git a/config.def.h b/config.def.h
2index 9855e21..d01bd38 100644
3--- a/config.def.h
4+++ b/config.def.h
5@@ -10,3 +10,6 @@ static const char *colorname[NUMCOLS] = {
6
7 /* treat a cleared input like a wrong password (color) */
8 static const int failonclear = 1;
9+
10+/* time in seconds before the monitor shuts down */
11+static const int monitortime = 5;
12diff --git a/slock.c b/slock.c
13index d2f0886..f65a43b 100644
14--- a/slock.c
15+++ b/slock.c
16@@ -15,6 +15,7 @@
17 #include <unistd.h>
18 #include <sys/types.h>
19 #include <X11/extensions/Xrandr.h>
20+#include <X11/extensions/dpms.h>
21 #include <X11/keysym.h>
22 #include <X11/Xlib.h>
23 #include <X11/Xutil.h>
24@@ -306,6 +307,7 @@ main(int argc, char **argv) {
25 const char *hash;
26 Display *dpy;
27 int s, nlocks, nscreens;
28+ CARD16 standby, suspend, off;
29
30 ARGBEGIN {
31 case 'v':
32@@ -366,6 +368,20 @@ main(int argc, char **argv) {
33 if (nlocks != nscreens)
34 return 1;
35
36+ /* DPMS magic to disable the monitor */
37+ if (!DPMSCapable(dpy))
38+ die("slock: DPMSCapable failed\n");
39+ if (!DPMSEnable(dpy))
40+ die("slock: DPMSEnable failed\n");
41+ if (!DPMSGetTimeouts(dpy, &standby, &suspend, &off))
42+ die("slock: DPMSGetTimeouts failed\n");
43+ if (!standby || !suspend || !off)
44+ die("slock: at least one DPMS variable is zero\n");
45+ if (!DPMSSetTimeouts(dpy, monitortime, monitortime, monitortime))
46+ die("slock: DPMSSetTimeouts failed\n");
47+
48+ XSync(dpy, 0);
49+
50 /* run post-lock command */
51 if (argc > 0) {
52 switch (fork()) {
53@@ -383,5 +399,9 @@ main(int argc, char **argv) {
54 /* everything is now blank. Wait for the correct password */
55 readpw(dpy, &rr, locks, nscreens, hash);
56
57+ /* reset DPMS values to inital ones */
58+ DPMSSetTimeouts(dpy, standby, suspend, off);
59+ XSync(dpy, 0);
60+
61 return 0;
62 }
diff --git a/slock/patches/slock-message-20191002-b46028b.diff b/slock/patches/slock-message-20191002-b46028b.diff
new file mode 100644
index 0000000..54b17e6
--- /dev/null
+++ b/slock/patches/slock-message-20191002-b46028b.diff
@@ -0,0 +1,250 @@
1From b46028b2797b886154258dcafe71c349cdc68b43 Mon Sep 17 00:00:00 2001
2From: Blair Drummond <blair.robert.drummond@gmail.com>
3Date: Wed, 2 Oct 2019 14:59:00 -0400
4Subject: [PATCH] Add a message command. Fixes old version's bugs.
5
6---
7 config.def.h | 9 ++++
8 config.mk | 2 +-
9 slock.1 | 7 +++
10 slock.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++--
11 4 files changed, 133 insertions(+), 5 deletions(-)
12
13diff --git a/config.def.h b/config.def.h
14index 9855e21..c2a0ab2 100644
15--- a/config.def.h
16+++ b/config.def.h
17@@ -10,3 +10,12 @@ static const char *colorname[NUMCOLS] = {
18
19 /* treat a cleared input like a wrong password (color) */
20 static const int failonclear = 1;
21+
22+/* default message */
23+static const char * message = "Suckless: Software that sucks less.";
24+
25+/* text color */
26+static const char * text_color = "#ffffff";
27+
28+/* text size (must be a valid size) */
29+static const char * font_name = "6x10";
30diff --git a/config.mk b/config.mk
31index 74429ae..c4ccf66 100644
32--- a/config.mk
33+++ b/config.mk
34@@ -12,7 +12,7 @@ X11LIB = /usr/X11R6/lib
35
36 # includes and libs
37 INCS = -I. -I/usr/include -I${X11INC}
38-LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr
39+LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -lXinerama
40
41 # flags
42 CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H
43diff --git a/slock.1 b/slock.1
44index 82cdcd6..946165f 100644
45--- a/slock.1
46+++ b/slock.1
47@@ -6,6 +6,8 @@
48 .Sh SYNOPSIS
49 .Nm
50 .Op Fl v
51+.Op Fl f
52+.Op Fl m Ar message
53 .Op Ar cmd Op Ar arg ...
54 .Sh DESCRIPTION
55 .Nm
56@@ -16,6 +18,11 @@ is executed after the screen has been locked.
57 .Bl -tag -width Ds
58 .It Fl v
59 Print version information to stdout and exit.
60+.It Fl f
61+List all valid X fonts and exit.
62+.It Fl m Ar message
63+Overrides default slock lock message.
64+.TP
65 .El
66 .Sh SECURITY CONSIDERATIONS
67 To make sure a locked screen can not be bypassed by switching VTs
68diff --git a/slock.c b/slock.c
69index 5ae738c..610929b 100644
70--- a/slock.c
71+++ b/slock.c
72@@ -15,6 +15,7 @@
73 #include <unistd.h>
74 #include <sys/types.h>
75 #include <X11/extensions/Xrandr.h>
76+#include <X11/extensions/Xinerama.h>
77 #include <X11/keysym.h>
78 #include <X11/Xlib.h>
79 #include <X11/Xutil.h>
80@@ -24,6 +25,9 @@
81
82 char *argv0;
83
84+/* global count to prevent repeated error messages */
85+int count_error = 0;
86+
87 enum {
88 INIT,
89 INPUT,
90@@ -83,6 +87,98 @@ dontkillme(void)
91 }
92 #endif
93
94+static void
95+writemessage(Display *dpy, Window win, int screen)
96+{
97+ int len, line_len, width, height, s_width, s_height, i, j, k, tab_replace, tab_size;
98+ XGCValues gr_values;
99+ XFontStruct *fontinfo;
100+ XColor color, dummy;
101+ XineramaScreenInfo *xsi;
102+ GC gc;
103+ fontinfo = XLoadQueryFont(dpy, font_name);
104+
105+ if (fontinfo == NULL) {
106+ if (count_error == 0) {
107+ fprintf(stderr, "slock: Unable to load font \"%s\"\n", font_name);
108+ fprintf(stderr, "slock: Try listing fonts with 'slock -f'\n");
109+ count_error++;
110+ }
111+ return;
112+ }
113+
114+ tab_size = 8 * XTextWidth(fontinfo, " ", 1);
115+
116+ XAllocNamedColor(dpy, DefaultColormap(dpy, screen),
117+ text_color, &color, &dummy);
118+
119+ gr_values.font = fontinfo->fid;
120+ gr_values.foreground = color.pixel;
121+ gc=XCreateGC(dpy,win,GCFont+GCForeground, &gr_values);
122+
123+ /* To prevent "Uninitialized" warnings. */
124+ xsi = NULL;
125+
126+ /*
127+ * Start formatting and drawing text
128+ */
129+
130+ len = strlen(message);
131+
132+ /* Max max line length (cut at '\n') */
133+ line_len = 0;
134+ k = 0;
135+ for (i = j = 0; i < len; i++) {
136+ if (message[i] == '\n') {
137+ if (i - j > line_len)
138+ line_len = i - j;
139+ k++;
140+ i++;
141+ j = i;
142+ }
143+ }
144+ /* If there is only one line */
145+ if (line_len == 0)
146+ line_len = len;
147+
148+ if (XineramaIsActive(dpy)) {
149+ xsi = XineramaQueryScreens(dpy, &i);
150+ s_width = xsi[0].width;
151+ s_height = xsi[0].height;
152+ } else {
153+ s_width = DisplayWidth(dpy, screen);
154+ s_height = DisplayHeight(dpy, screen);
155+ }
156+
157+ height = s_height*3/7 - (k*20)/3;
158+ width = (s_width - XTextWidth(fontinfo, message, line_len))/2;
159+
160+ /* Look for '\n' and print the text between them. */
161+ for (i = j = k = 0; i <= len; i++) {
162+ /* i == len is the special case for the last line */
163+ if (i == len || message[i] == '\n') {
164+ tab_replace = 0;
165+ while (message[j] == '\t' && j < i) {
166+ tab_replace++;
167+ j++;
168+ }
169+
170+ XDrawString(dpy, win, gc, width + tab_size*tab_replace, height + 20*k, message + j, i - j);
171+ while (i < len && message[i] == '\n') {
172+ i++;
173+ j = i;
174+ k++;
175+ }
176+ }
177+ }
178+
179+ /* xsi should not be NULL anyway if Xinerama is active, but to be safe */
180+ if (XineramaIsActive(dpy) && xsi != NULL)
181+ XFree(xsi);
182+}
183+
184+
185+
186 static const char *
187 gethash(void)
188 {
189@@ -194,6 +290,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
190 locks[screen]->win,
191 locks[screen]->colors[color]);
192 XClearWindow(dpy, locks[screen]->win);
193+ writemessage(dpy, locks[screen]->win, screen);
194 }
195 oldc = color;
196 }
197@@ -300,7 +397,7 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
198 static void
199 usage(void)
200 {
201- die("usage: slock [-v] [cmd [arg ...]]\n");
202+ die("usage: slock [-v] [-f] [-m message] [cmd [arg ...]]\n");
203 }
204
205 int
206@@ -313,12 +410,25 @@ main(int argc, char **argv) {
207 gid_t dgid;
208 const char *hash;
209 Display *dpy;
210- int s, nlocks, nscreens;
211+ int i, s, nlocks, nscreens;
212+ int count_fonts;
213+ char **font_names;
214
215 ARGBEGIN {
216 case 'v':
217 fprintf(stderr, "slock-"VERSION"\n");
218 return 0;
219+ case 'm':
220+ message = EARGF(usage());
221+ break;
222+ case 'f':
223+ if (!(dpy = XOpenDisplay(NULL)))
224+ die("slock: cannot open display\n");
225+ font_names = XListFonts(dpy, "*", 10000 /* list 10000 fonts*/, &count_fonts);
226+ for (i=0; i<count_fonts; i++) {
227+ fprintf(stderr, "%s\n", *(font_names+i));
228+ }
229+ return 0;
230 default:
231 usage();
232 } ARGEND
233@@ -363,10 +473,12 @@ main(int argc, char **argv) {
234 if (!(locks = calloc(nscreens, sizeof(struct lock *))))
235 die("slock: out of memory\n");
236 for (nlocks = 0, s = 0; s < nscreens; s++) {
237- if ((locks[s] = lockscreen(dpy, &rr, s)) != NULL)
238+ if ((locks[s] = lockscreen(dpy, &rr, s)) != NULL) {
239+ writemessage(dpy, locks[s]->win, s);
240 nlocks++;
241- else
242+ } else {
243 break;
244+ }
245 }
246 XSync(dpy, 0);
247
248--
2492.20.1
250
diff --git a/st/config.h b/st/config.h
new file mode 100644
index 0000000..23ea70a
--- /dev/null
+++ b/st/config.h
@@ -0,0 +1,473 @@
1/* See LICENSE file for copyright and license details. */
2
3/*
4 * appearance
5 *
6 * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
7 */
8static char *font = "Hermit:pixelsize=12:antialias=true:autohint=true";
9static int borderpx = 9;
10
11/*
12 * What program is execed by st depends of these precedence rules:
13 * 1: program passed with -e
14 * 2: scroll and/or utmp
15 * 3: SHELL environment variable
16 * 4: value of shell in /etc/passwd
17 * 5: value of shell in config.h
18 */
19static char *shell = "/bin/sh";
20char *utmp = NULL;
21/* scroll program: to enable use a string like "scroll" */
22char *scroll = NULL;
23char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
24
25/* identification sequence returned in DA and DECID */
26char *vtiden = "\033[?6c";
27
28/* Kerning / character bounding-box multipliers */
29static float cwscale = 1.0;
30static float chscale = 1.0;
31
32/*
33 * word delimiter string
34 *
35 * More advanced example: L" `'\"()[]{}"
36 */
37wchar_t *worddelimiters = L" ";
38
39/* selection timeouts (in milliseconds) */
40static unsigned int doubleclicktimeout = 300;
41static unsigned int tripleclicktimeout = 600;
42
43/* alt screens */
44int allowaltscreen = 1;
45
46/*
47 * draw latency range in ms - from new content/keypress/etc until drawing.
48 * within this range, st draws when content stops arriving (idle). mostly it's
49 * near minlatency, but it waits longer for slow updates to avoid partial draw.
50 * low minlatency will tear/flicker more, as it can "detect" idle too early.
51 */
52static double minlatency = 8;
53static double maxlatency = 33;
54
55/*
56 * blinking timeout (set to 0 to disable blinking) for the terminal blinking
57 * attribute.
58 */
59static unsigned int blinktimeout = 800;
60
61/*
62 * thickness of underline and bar cursors
63 */
64static unsigned int cursorthickness = 2;
65
66/*
67 * bell volume. It must be a value between -100 and 100. Use 0 for disabling
68 * it
69 */
70static int bellvolume = 0;
71
72/* default TERM value */
73char *termname = "st-256color";
74
75/*
76 * spaces per tab
77 *
78 * When you are changing this value, don't forget to adapt the »it« value in
79 * the st.info and appropriately install the st.info in the environment where
80 * you use this st version.
81 *
82 * it#$tabspaces,
83 *
84 * Secondly make sure your kernel is not expanding tabs. When running `stty
85 * -a` »tab0« should appear. You can tell the terminal to not expand tabs by
86 * running following command:
87 *
88 * stty tabs
89 */
90unsigned int tabspaces = 8;
91
92/* Terminal colors (16 first used in escape sequence) */
93static const char *colorname[] = {
94 /* 8 normal colors */
95 "black",
96 "red3",
97 "green3",
98 "yellow3",
99 "blue2",
100 "magenta3",
101 "cyan3",
102 "gray90",
103
104 /* 8 bright colors */
105 "gray50",
106 "red",
107 "green",
108 "yellow",
109 "#5c5cff",
110 "magenta",
111 "cyan",
112 "white",
113
114 [255] = 0,
115
116 /* more colors can be added after 255 to use with DefaultXX */
117 "#cccccc",
118 "#555555",
119};
120
121
122/*
123 * Default colors (colorname index)
124 * foreground, background, cursor, reverse cursor
125 */
126unsigned int defaultfg = 7;
127unsigned int defaultbg = 0;
128static unsigned int defaultcs = 256;
129static unsigned int defaultrcs = 257;
130
131/*
132 * Default shape of cursor
133 * 2: Block ("â–ˆ")
134 * 4: Underline ("_")
135 * 6: Bar ("|")
136 * 7: Snowman ("☃")
137 */
138static unsigned int cursorshape = 2;
139
140/*
141 * Default columns and rows numbers
142 */
143
144static unsigned int cols = 80;
145static unsigned int rows = 24;
146
147/*
148 * Default colour and shape of the mouse cursor
149 */
150static unsigned int mouseshape = XC_xterm;
151static unsigned int mousefg = 7;
152static unsigned int mousebg = 0;
153
154/*
155 * Color used to display font attributes when fontconfig selected a font which
156 * doesn't match the ones requested.
157 */
158static unsigned int defaultattr = 11;
159
160/*
161 * Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
162 * Note that if you want to use ShiftMask with selmasks, set this to an other
163 * modifier, set to 0 to not use it.
164 */
165static uint forcemousemod = ShiftMask;
166
167/*
168 * Internal mouse shortcuts.
169 * Beware that overloading Button1 will disable the selection.
170 */
171static MouseShortcut mshortcuts[] = {
172 /* mask button function argument release */
173 { XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, /* !alt */ -1 },
174 { XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, /* !alt */ -1 },
175 { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
176 { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
177 { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
178 { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
179 { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
180};
181
182/* Internal keyboard shortcuts. */
183#define MODKEY Mod1Mask
184#define TERMMOD (ControlMask|ShiftMask)
185
186static Shortcut shortcuts[] = {
187 /* mask keysym function argument */
188 { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
189 { ControlMask, XK_Print, toggleprinter, {.i = 0} },
190 { ShiftMask, XK_Print, printscreen, {.i = 0} },
191 { XK_ANY_MOD, XK_Print, printsel, {.i = 0} },
192 { TERMMOD, XK_Prior, zoom, {.f = +1} },
193 { TERMMOD, XK_Next, zoom, {.f = -1} },
194 { TERMMOD, XK_Home, zoomreset, {.f = 0} },
195 { TERMMOD, XK_C, clipcopy, {.i = 0} },
196 { TERMMOD, XK_V, clippaste, {.i = 0} },
197 { TERMMOD, XK_Y, selpaste, {.i = 0} },
198 { ShiftMask, XK_Insert, selpaste, {.i = 0} },
199 { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
200 { MODKEY, XK_l, copyurl, {.i = 0} },
201 { ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
202 { ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
203};
204
205/*
206 * Special keys (change & recompile st.info accordingly)
207 *
208 * Mask value:
209 * * Use XK_ANY_MOD to match the key no matter modifiers state
210 * * Use XK_NO_MOD to match the key alone (no modifiers)
211 * appkey value:
212 * * 0: no value
213 * * > 0: keypad application mode enabled
214 * * = 2: term.numlock = 1
215 * * < 0: keypad application mode disabled
216 * appcursor value:
217 * * 0: no value
218 * * > 0: cursor application mode enabled
219 * * < 0: cursor application mode disabled
220 *
221 * Be careful with the order of the definitions because st searches in
222 * this table sequentially, so any XK_ANY_MOD must be in the last
223 * position for a key.
224 */
225
226/*
227 * If you want keys other than the X11 function keys (0xFD00 - 0xFFFF)
228 * to be mapped below, add them to this array.
229 */
230static KeySym mappedkeys[] = { -1 };
231
232/*
233 * State bits to ignore when matching key or button events. By default,
234 * numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored.
235 */
236static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
237
238/*
239 * This is the huge key array which defines all compatibility to the Linux
240 * world. Please decide about changes wisely.
241 */
242static Key key[] = {
243 /* keysym mask string appkey appcursor */
244 { XK_KP_Home, ShiftMask, "\033[2J", 0, -1},
245 { XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1},
246 { XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1},
247 { XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1},
248 { XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0},
249 { XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1},
250 { XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1},
251 { XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0},
252 { XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1},
253 { XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1},
254 { XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0},
255 { XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1},
256 { XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1},
257 { XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0},
258 { XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1},
259 { XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1},
260 { XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0},
261 { XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
262 { XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0},
263 { XK_KP_End, ControlMask, "\033[J", -1, 0},
264 { XK_KP_End, ControlMask, "\033[1;5F", +1, 0},
265 { XK_KP_End, ShiftMask, "\033[K", -1, 0},
266 { XK_KP_End, ShiftMask, "\033[1;2F", +1, 0},
267 { XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0},
268 { XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0},
269 { XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0},
270 { XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0},
271 { XK_KP_Insert, ShiftMask, "\033[4l", -1, 0},
272 { XK_KP_Insert, ControlMask, "\033[L", -1, 0},
273 { XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0},
274 { XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
275 { XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
276 { XK_KP_Delete, ControlMask, "\033[M", -1, 0},
277 { XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0},
278 { XK_KP_Delete, ShiftMask, "\033[2K", -1, 0},
279 { XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0},
280 { XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0},
281 { XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
282 { XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0},
283 { XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0},
284 { XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0},
285 { XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0},
286 { XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0},
287 { XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0},
288 { XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0},
289 { XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0},
290 { XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0},
291 { XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0},
292 { XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0},
293 { XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0},
294 { XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0},
295 { XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0},
296 { XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0},
297 { XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0},
298 { XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0},
299 { XK_Up, ShiftMask, "\033[1;2A", 0, 0},
300 { XK_Up, Mod1Mask, "\033[1;3A", 0, 0},
301 { XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0},
302 { XK_Up, ControlMask, "\033[1;5A", 0, 0},
303 { XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0},
304 { XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0},
305 { XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0},
306 { XK_Up, XK_ANY_MOD, "\033[A", 0, -1},
307 { XK_Up, XK_ANY_MOD, "\033OA", 0, +1},
308 { XK_Down, ShiftMask, "\033[1;2B", 0, 0},
309 { XK_Down, Mod1Mask, "\033[1;3B", 0, 0},
310 { XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0},
311 { XK_Down, ControlMask, "\033[1;5B", 0, 0},
312 { XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0},
313 { XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0},
314 { XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0},
315 { XK_Down, XK_ANY_MOD, "\033[B", 0, -1},
316 { XK_Down, XK_ANY_MOD, "\033OB", 0, +1},
317 { XK_Left, ShiftMask, "\033[1;2D", 0, 0},
318 { XK_Left, Mod1Mask, "\033[1;3D", 0, 0},
319 { XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0},
320 { XK_Left, ControlMask, "\033[1;5D", 0, 0},
321 { XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0},
322 { XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0},
323 { XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0},
324 { XK_Left, XK_ANY_MOD, "\033[D", 0, -1},
325 { XK_Left, XK_ANY_MOD, "\033OD", 0, +1},
326 { XK_Right, ShiftMask, "\033[1;2C", 0, 0},
327 { XK_Right, Mod1Mask, "\033[1;3C", 0, 0},
328 { XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0},
329 { XK_Right, ControlMask, "\033[1;5C", 0, 0},
330 { XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0},
331 { XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0},
332 { XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0},
333 { XK_Right, XK_ANY_MOD, "\033[C", 0, -1},
334 { XK_Right, XK_ANY_MOD, "\033OC", 0, +1},
335 { XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0},
336 { XK_Return, Mod1Mask, "\033\r", 0, 0},
337 { XK_Return, XK_ANY_MOD, "\r", 0, 0},
338 { XK_Insert, ShiftMask, "\033[4l", -1, 0},
339 { XK_Insert, ShiftMask, "\033[2;2~", +1, 0},
340 { XK_Insert, ControlMask, "\033[L", -1, 0},
341 { XK_Insert, ControlMask, "\033[2;5~", +1, 0},
342 { XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
343 { XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
344 { XK_Delete, ControlMask, "\033[M", -1, 0},
345 { XK_Delete, ControlMask, "\033[3;5~", +1, 0},
346 { XK_Delete, ShiftMask, "\033[2K", -1, 0},
347 { XK_Delete, ShiftMask, "\033[3;2~", +1, 0},
348 { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0},
349 { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
350 { XK_BackSpace, XK_NO_MOD, "\177", 0, 0},
351 { XK_BackSpace, Mod1Mask, "\033\177", 0, 0},
352 { XK_Home, ShiftMask, "\033[2J", 0, -1},
353 { XK_Home, ShiftMask, "\033[1;2H", 0, +1},
354 { XK_Home, XK_ANY_MOD, "\033[H", 0, -1},
355 { XK_Home, XK_ANY_MOD, "\033[1~", 0, +1},
356 { XK_End, ControlMask, "\033[J", -1, 0},
357 { XK_End, ControlMask, "\033[1;5F", +1, 0},
358 { XK_End, ShiftMask, "\033[K", -1, 0},
359 { XK_End, ShiftMask, "\033[1;2F", +1, 0},
360 { XK_End, XK_ANY_MOD, "\033[4~", 0, 0},
361 { XK_Prior, ControlMask, "\033[5;5~", 0, 0},
362 { XK_Prior, ShiftMask, "\033[5;2~", 0, 0},
363 { XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
364 { XK_Next, ControlMask, "\033[6;5~", 0, 0},
365 { XK_Next, ShiftMask, "\033[6;2~", 0, 0},
366 { XK_Next, XK_ANY_MOD, "\033[6~", 0, 0},
367 { XK_F1, XK_NO_MOD, "\033OP" , 0, 0},
368 { XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0},
369 { XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0},
370 { XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0},
371 { XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0},
372 { XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0},
373 { XK_F2, XK_NO_MOD, "\033OQ" , 0, 0},
374 { XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0},
375 { XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0},
376 { XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0},
377 { XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0},
378 { XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0},
379 { XK_F3, XK_NO_MOD, "\033OR" , 0, 0},
380 { XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0},
381 { XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0},
382 { XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0},
383 { XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0},
384 { XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0},
385 { XK_F4, XK_NO_MOD, "\033OS" , 0, 0},
386 { XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0},
387 { XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0},
388 { XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0},
389 { XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0},
390 { XK_F5, XK_NO_MOD, "\033[15~", 0, 0},
391 { XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0},
392 { XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0},
393 { XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0},
394 { XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0},
395 { XK_F6, XK_NO_MOD, "\033[17~", 0, 0},
396 { XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0},
397 { XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0},
398 { XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0},
399 { XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0},
400 { XK_F7, XK_NO_MOD, "\033[18~", 0, 0},
401 { XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0},
402 { XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0},
403 { XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0},
404 { XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0},
405 { XK_F8, XK_NO_MOD, "\033[19~", 0, 0},
406 { XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0},
407 { XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0},
408 { XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0},
409 { XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0},
410 { XK_F9, XK_NO_MOD, "\033[20~", 0, 0},
411 { XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0},
412 { XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0},
413 { XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0},
414 { XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0},
415 { XK_F10, XK_NO_MOD, "\033[21~", 0, 0},
416 { XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0},
417 { XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0},
418 { XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0},
419 { XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0},
420 { XK_F11, XK_NO_MOD, "\033[23~", 0, 0},
421 { XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0},
422 { XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0},
423 { XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0},
424 { XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0},
425 { XK_F12, XK_NO_MOD, "\033[24~", 0, 0},
426 { XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0},
427 { XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0},
428 { XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0},
429 { XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0},
430 { XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0},
431 { XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0},
432 { XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0},
433 { XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0},
434 { XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0},
435 { XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0},
436 { XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0},
437 { XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0},
438 { XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0},
439 { XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0},
440 { XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0},
441 { XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0},
442 { XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0},
443 { XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0},
444 { XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0},
445 { XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0},
446 { XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0},
447 { XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0},
448 { XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0},
449 { XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0},
450 { XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0},
451 { XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0},
452 { XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0},
453};
454
455/*
456 * Selection types' masks.
457 * Use the same masks as usual.
458 * Button1Mask is always unset, to make masks match between ButtonPress.
459 * ButtonRelease and MotionNotify.
460 * If no match is found, regular selection is used.
461 */
462static uint selmasks[] = {
463 [SEL_RECTANGULAR] = Mod1Mask,
464};
465
466/*
467 * Printable characters in ASCII, used to estimate the advance width
468 * of single wide characters.
469 */
470static char ascii_printable[] =
471 " !\"#$%&'()*+,-./0123456789:;<=>?"
472 "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
473 "`abcdefghijklmnopqrstuvwxyz{|}~";
diff --git a/st/patches/st-copyurl-20190202-0.8.1.diff b/st/patches/st-copyurl-20190202-0.8.1.diff
new file mode 100644
index 0000000..8d6782b
--- /dev/null
+++ b/st/patches/st-copyurl-20190202-0.8.1.diff
@@ -0,0 +1,109 @@
1From be408247f1c1ff8ccf7ab128b126f54d19bd4392 Mon Sep 17 00:00:00 2001
2From: Michael Buch <michaelbuch12@gmail.com>
3Date: Sat, 2 Feb 2019 14:20:52 +0000
4Subject: [PATCH] Port the copyurl patch to the 0.8.1 st release. Mainly fix
5 usage of depracted selcopy
6
7---
8 config.def.h | 1 +
9 st.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++
10 st.h | 1 +
11 3 files changed, 64 insertions(+)
12
13diff --git a/config.def.h b/config.def.h
14index 82b1b09..cbe923e 100644
15--- a/config.def.h
16+++ b/config.def.h
17@@ -178,6 +178,7 @@ static Shortcut shortcuts[] = {
18 { TERMMOD, XK_Y, selpaste, {.i = 0} },
19 { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
20 { TERMMOD, XK_I, iso14755, {.i = 0} },
21+ { MODKEY, XK_l, copyurl, {.i = 0} },
22 };
23
24 /*
25diff --git a/st.c b/st.c
26index 46c954b..476eb31 100644
27--- a/st.c
28+++ b/st.c
29@@ -2616,3 +2616,65 @@ redraw(void)
30 tfulldirt();
31 draw();
32 }
33+
34+/* select and copy the previous url on screen (do nothing if there's no url).
35+ * known bug: doesn't handle urls that span multiple lines (wontfix)
36+ * known bug: only finds first url on line (mightfix)
37+ */
38+void
39+copyurl(const Arg *arg) {
40+ /* () and [] can appear in urls, but excluding them here will reduce false
41+ * positives when figuring out where a given url ends.
42+ */
43+ static char URLCHARS[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
44+ "abcdefghijklmnopqrstuvwxyz"
45+ "0123456789-._~:/?#@!$&'*+,;=%";
46+
47+ int i, row, startrow;
48+ char *linestr = calloc(sizeof(char), term.col+1); /* assume ascii */
49+ char *c, *match = NULL;
50+
51+ row = (sel.ob.x >= 0 && sel.nb.y > 0) ? sel.nb.y-1 : term.bot;
52+ LIMIT(row, term.top, term.bot);
53+ startrow = row;
54+
55+ /* find the start of the last url before selection */
56+ do {
57+ for (i = 0; i < term.col; ++i) {
58+ if (term.line[row][i].u > 127) /* assume ascii */
59+ continue;
60+ linestr[i] = term.line[row][i].u;
61+ }
62+ linestr[term.col] = '\0';
63+ if ((match = strstr(linestr, "http://"))
64+ || (match = strstr(linestr, "https://")))
65+ break;
66+ if (--row < term.top)
67+ row = term.bot;
68+ } while (row != startrow);
69+
70+ if (match) {
71+ /* must happen before trim */
72+ selclear();
73+ sel.ob.x = strlen(linestr) - strlen(match);
74+
75+ /* trim the rest of the line from the url match */
76+ for (c = match; *c != '\0'; ++c)
77+ if (!strchr(URLCHARS, *c)) {
78+ *c = '\0';
79+ break;
80+ }
81+
82+ /* select and copy */
83+ sel.mode = 1;
84+ sel.type = SEL_REGULAR;
85+ sel.oe.x = sel.ob.x + strlen(match)-1;
86+ sel.ob.y = sel.oe.y = row;
87+ selnormalize();
88+ tsetdirt(sel.nb.y, sel.ne.y);
89+ xsetsel(getsel());
90+ xclipcopy();
91+ }
92+
93+ free(linestr);
94+}
95diff --git a/st.h b/st.h
96index dac64d8..5a58f8f 100644
97--- a/st.h
98+++ b/st.h
99@@ -85,6 +85,7 @@ void printscreen(const Arg *);
100 void printsel(const Arg *);
101 void sendbreak(const Arg *);
102 void toggleprinter(const Arg *);
103+void copyurl(const Arg *);
104
105 int tattrset(int);
106 void tnew(int, int);
107--
1082.20.1
109
diff --git a/st/patches/st-hidecursor-0.8.1.diff b/st/patches/st-hidecursor-0.8.1.diff
new file mode 100644
index 0000000..d27267c
--- /dev/null
+++ b/st/patches/st-hidecursor-0.8.1.diff
@@ -0,0 +1,88 @@
1diff --git a/x.c b/x.c
2index c343ba2..a40de8c 100644
3--- a/x.c
4+++ b/x.c
5@@ -96,6 +96,11 @@ typedef struct {
6 Draw draw;
7 Visual *vis;
8 XSetWindowAttributes attrs;
9+ /* Here, we use the term *pointer* to differentiate the cursor
10+ * one sees when hovering the mouse over the terminal from, e.g.,
11+ * a green rectangle where text would be entered. */
12+ Cursor vpointer, bpointer; /* visible and hidden pointers */
13+ int pointerisvisible;
14 int scr;
15 int isfixed; /* is fixed geometry? */
16 int l, t; /* left and top offset */
17@@ -652,6 +657,13 @@ brelease(XEvent *e)
18 void
19 bmotion(XEvent *e)
20 {
21+ if (!xw.pointerisvisible) {
22+ XDefineCursor(xw.dpy, xw.win, xw.vpointer);
23+ xw.pointerisvisible = 1;
24+ if (!IS_SET(MODE_MOUSEMANY))
25+ xsetpointermotion(0);
26+ }
27+
28 if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
29 mousereport(e);
30 return;
31@@ -997,10 +1009,10 @@ void
32 xinit(int cols, int rows)
33 {
34 XGCValues gcvalues;
35- Cursor cursor;
36 Window parent;
37 pid_t thispid = getpid();
38 XColor xmousefg, xmousebg;
39+ Pixmap blankpm;
40
41 if (!(xw.dpy = XOpenDisplay(NULL)))
42 die("Can't open display\n");
43@@ -1076,8 +1088,9 @@ xinit(int cols, int rows)
44 die("XCreateIC failed. Could not obtain input method.\n");
45
46 /* white cursor, black outline */
47- cursor = XCreateFontCursor(xw.dpy, mouseshape);
48- XDefineCursor(xw.dpy, xw.win, cursor);
49+ xw.pointerisvisible = 1;
50+ xw.vpointer = XCreateFontCursor(xw.dpy, mouseshape);
51+ XDefineCursor(xw.dpy, xw.win, xw.vpointer);
52
53 if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
54 xmousefg.red = 0xffff;
55@@ -1091,7 +1104,10 @@ xinit(int cols, int rows)
56 xmousebg.blue = 0x0000;
57 }
58
59- XRecolorCursor(xw.dpy, cursor, &xmousefg, &xmousebg);
60+ XRecolorCursor(xw.dpy, xw.vpointer, &xmousefg, &xmousebg);
61+ blankpm = XCreateBitmapFromData(xw.dpy, xw.win, &(char){0}, 1, 1);
62+ xw.bpointer = XCreatePixmapCursor(xw.dpy, blankpm, blankpm,
63+ &xmousefg, &xmousebg, 0, 0);
64
65 xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
66 xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
67@@ -1574,6 +1590,8 @@ unmap(XEvent *ev)
68 void
69 xsetpointermotion(int set)
70 {
71+ if (!set && !xw.pointerisvisible)
72+ return;
73 MODBIT(xw.attrs.event_mask, set, PointerMotionMask);
74 XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
75 }
76@@ -1692,6 +1710,12 @@ kpress(XEvent *ev)
77 Status status;
78 Shortcut *bp;
79
80+ if (xw.pointerisvisible) {
81+ XDefineCursor(xw.dpy, xw.win, xw.bpointer);
82+ xsetpointermotion(1);
83+ xw.pointerisvisible = 0;
84+ }
85+
86 if (IS_SET(MODE_KBDLOCK))
87 return;
88
diff --git a/st/patches/st-scrollback-20200419-72e3f6c.diff b/st/patches/st-scrollback-20200419-72e3f6c.diff
new file mode 100644
index 0000000..e72999c
--- /dev/null
+++ b/st/patches/st-scrollback-20200419-72e3f6c.diff
@@ -0,0 +1,351 @@
1diff --git a/config.def.h b/config.def.h
2index 0895a1f..eef24df 100644
3--- a/config.def.h
4+++ b/config.def.h
5@@ -188,6 +188,8 @@ static Shortcut shortcuts[] = {
6 { TERMMOD, XK_Y, selpaste, {.i = 0} },
7 { ShiftMask, XK_Insert, selpaste, {.i = 0} },
8 { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
9+ { ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
10+ { ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
11 };
12
13 /*
14diff --git a/st.c b/st.c
15index 0ce6ac2..641edc0 100644
16--- a/st.c
17+++ b/st.c
18@@ -35,6 +35,7 @@
19 #define ESC_ARG_SIZ 16
20 #define STR_BUF_SIZ ESC_BUF_SIZ
21 #define STR_ARG_SIZ ESC_ARG_SIZ
22+#define HISTSIZE 2000
23
24 /* macros */
25 #define IS_SET(flag) ((term.mode & (flag)) != 0)
26@@ -42,6 +43,9 @@
27 #define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f))
28 #define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c))
29 #define ISDELIM(u) (u && wcschr(worddelimiters, u))
30+#define TLINE(y) ((y) < term.scr ? term.hist[((y) + term.histi - \
31+ term.scr + HISTSIZE + 1) % HISTSIZE] : \
32+ term.line[(y) - term.scr])
33
34 enum term_mode {
35 MODE_WRAP = 1 << 0,
36@@ -117,6 +121,9 @@ typedef struct {
37 int col; /* nb col */
38 Line *line; /* screen */
39 Line *alt; /* alternate screen */
40+ Line hist[HISTSIZE]; /* history buffer */
41+ int histi; /* history index */
42+ int scr; /* scroll back */
43 int *dirty; /* dirtyness of lines */
44 TCursor c; /* cursor */
45 int ocx; /* old cursor col */
46@@ -185,8 +192,8 @@ static void tnewline(int);
47 static void tputtab(int);
48 static void tputc(Rune);
49 static void treset(void);
50-static void tscrollup(int, int);
51-static void tscrolldown(int, int);
52+static void tscrollup(int, int, int);
53+static void tscrolldown(int, int, int);
54 static void tsetattr(int *, int);
55 static void tsetchar(Rune, Glyph *, int, int);
56 static void tsetdirt(int, int);
57@@ -415,10 +422,10 @@ tlinelen(int y)
58 {
59 int i = term.col;
60
61- if (term.line[y][i - 1].mode & ATTR_WRAP)
62+ if (TLINE(y)[i - 1].mode & ATTR_WRAP)
63 return i;
64
65- while (i > 0 && term.line[y][i - 1].u == ' ')
66+ while (i > 0 && TLINE(y)[i - 1].u == ' ')
67 --i;
68
69 return i;
70@@ -527,7 +534,7 @@ selsnap(int *x, int *y, int direction)
71 * Snap around if the word wraps around at the end or
72 * beginning of a line.
73 */
74- prevgp = &term.line[*y][*x];
75+ prevgp = &TLINE(*y)[*x];
76 prevdelim = ISDELIM(prevgp->u);
77 for (;;) {
78 newx = *x + direction;
79@@ -542,14 +549,14 @@ selsnap(int *x, int *y, int direction)
80 yt = *y, xt = *x;
81 else
82 yt = newy, xt = newx;
83- if (!(term.line[yt][xt].mode & ATTR_WRAP))
84+ if (!(TLINE(yt)[xt].mode & ATTR_WRAP))
85 break;
86 }
87
88 if (newx >= tlinelen(newy))
89 break;
90
91- gp = &term.line[newy][newx];
92+ gp = &TLINE(newy)[newx];
93 delim = ISDELIM(gp->u);
94 if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim
95 || (delim && gp->u != prevgp->u)))
96@@ -570,14 +577,14 @@ selsnap(int *x, int *y, int direction)
97 *x = (direction < 0) ? 0 : term.col - 1;
98 if (direction < 0) {
99 for (; *y > 0; *y += direction) {
100- if (!(term.line[*y-1][term.col-1].mode
101+ if (!(TLINE(*y-1)[term.col-1].mode
102 & ATTR_WRAP)) {
103 break;
104 }
105 }
106 } else if (direction > 0) {
107 for (; *y < term.row-1; *y += direction) {
108- if (!(term.line[*y][term.col-1].mode
109+ if (!(TLINE(*y)[term.col-1].mode
110 & ATTR_WRAP)) {
111 break;
112 }
113@@ -608,13 +615,13 @@ getsel(void)
114 }
115
116 if (sel.type == SEL_RECTANGULAR) {
117- gp = &term.line[y][sel.nb.x];
118+ gp = &TLINE(y)[sel.nb.x];
119 lastx = sel.ne.x;
120 } else {
121- gp = &term.line[y][sel.nb.y == y ? sel.nb.x : 0];
122+ gp = &TLINE(y)[sel.nb.y == y ? sel.nb.x : 0];
123 lastx = (sel.ne.y == y) ? sel.ne.x : term.col-1;
124 }
125- last = &term.line[y][MIN(lastx, linelen-1)];
126+ last = &TLINE(y)[MIN(lastx, linelen-1)];
127 while (last >= gp && last->u == ' ')
128 --last;
129
130@@ -849,6 +856,9 @@ void
131 ttywrite(const char *s, size_t n, int may_echo)
132 {
133 const char *next;
134+ Arg arg = (Arg) { .i = term.scr };
135+
136+ kscrolldown(&arg);
137
138 if (may_echo && IS_SET(MODE_ECHO))
139 twrite(s, n, 1);
140@@ -1060,13 +1070,53 @@ tswapscreen(void)
141 }
142
143 void
144-tscrolldown(int orig, int n)
145+kscrolldown(const Arg* a)
146+{
147+ int n = a->i;
148+
149+ if (n < 0)
150+ n = term.row + n;
151+
152+ if (n > term.scr)
153+ n = term.scr;
154+
155+ if (term.scr > 0) {
156+ term.scr -= n;
157+ selscroll(0, -n);
158+ tfulldirt();
159+ }
160+}
161+
162+void
163+kscrollup(const Arg* a)
164+{
165+ int n = a->i;
166+
167+ if (n < 0)
168+ n = term.row + n;
169+
170+ if (term.scr <= HISTSIZE-n) {
171+ term.scr += n;
172+ selscroll(0, n);
173+ tfulldirt();
174+ }
175+}
176+
177+void
178+tscrolldown(int orig, int n, int copyhist)
179 {
180 int i;
181 Line temp;
182
183 LIMIT(n, 0, term.bot-orig+1);
184
185+ if (copyhist) {
186+ term.histi = (term.histi - 1 + HISTSIZE) % HISTSIZE;
187+ temp = term.hist[term.histi];
188+ term.hist[term.histi] = term.line[term.bot];
189+ term.line[term.bot] = temp;
190+ }
191+
192 tsetdirt(orig, term.bot-n);
193 tclearregion(0, term.bot-n+1, term.col-1, term.bot);
194
195@@ -1076,17 +1126,28 @@ tscrolldown(int orig, int n)
196 term.line[i-n] = temp;
197 }
198
199- selscroll(orig, n);
200+ if (term.scr == 0)
201+ selscroll(orig, n);
202 }
203
204 void
205-tscrollup(int orig, int n)
206+tscrollup(int orig, int n, int copyhist)
207 {
208 int i;
209 Line temp;
210
211 LIMIT(n, 0, term.bot-orig+1);
212
213+ if (copyhist) {
214+ term.histi = (term.histi + 1) % HISTSIZE;
215+ temp = term.hist[term.histi];
216+ term.hist[term.histi] = term.line[orig];
217+ term.line[orig] = temp;
218+ }
219+
220+ if (term.scr > 0 && term.scr < HISTSIZE)
221+ term.scr = MIN(term.scr + n, HISTSIZE-1);
222+
223 tclearregion(0, orig, term.col-1, orig+n-1);
224 tsetdirt(orig+n, term.bot);
225
226@@ -1096,7 +1157,8 @@ tscrollup(int orig, int n)
227 term.line[i+n] = temp;
228 }
229
230- selscroll(orig, -n);
231+ if (term.scr == 0)
232+ selscroll(orig, -n);
233 }
234
235 void
236@@ -1135,7 +1197,7 @@ tnewline(int first_col)
237 int y = term.c.y;
238
239 if (y == term.bot) {
240- tscrollup(term.top, 1);
241+ tscrollup(term.top, 1, 1);
242 } else {
243 y++;
244 }
245@@ -1300,14 +1362,14 @@ void
246 tinsertblankline(int n)
247 {
248 if (BETWEEN(term.c.y, term.top, term.bot))
249- tscrolldown(term.c.y, n);
250+ tscrolldown(term.c.y, n, 0);
251 }
252
253 void
254 tdeleteline(int n)
255 {
256 if (BETWEEN(term.c.y, term.top, term.bot))
257- tscrollup(term.c.y, n);
258+ tscrollup(term.c.y, n, 0);
259 }
260
261 int32_t
262@@ -1738,11 +1800,11 @@ csihandle(void)
263 break;
264 case 'S': /* SU -- Scroll <n> line up */
265 DEFAULT(csiescseq.arg[0], 1);
266- tscrollup(term.top, csiescseq.arg[0]);
267+ tscrollup(term.top, csiescseq.arg[0], 0);
268 break;
269 case 'T': /* SD -- Scroll <n> line down */
270 DEFAULT(csiescseq.arg[0], 1);
271- tscrolldown(term.top, csiescseq.arg[0]);
272+ tscrolldown(term.top, csiescseq.arg[0], 0);
273 break;
274 case 'L': /* IL -- Insert <n> blank lines */
275 DEFAULT(csiescseq.arg[0], 1);
276@@ -2248,7 +2310,7 @@ eschandle(uchar ascii)
277 return 0;
278 case 'D': /* IND -- Linefeed */
279 if (term.c.y == term.bot) {
280- tscrollup(term.top, 1);
281+ tscrollup(term.top, 1, 1);
282 } else {
283 tmoveto(term.c.x, term.c.y+1);
284 }
285@@ -2261,7 +2323,7 @@ eschandle(uchar ascii)
286 break;
287 case 'M': /* RI -- Reverse index */
288 if (term.c.y == term.top) {
289- tscrolldown(term.top, 1);
290+ tscrolldown(term.top, 1, 1);
291 } else {
292 tmoveto(term.c.x, term.c.y-1);
293 }
294@@ -2482,7 +2544,7 @@ twrite(const char *buf, int buflen, int show_ctrl)
295 void
296 tresize(int col, int row)
297 {
298- int i;
299+ int i, j;
300 int minrow = MIN(row, term.row);
301 int mincol = MIN(col, term.col);
302 int *bp;
303@@ -2519,6 +2581,14 @@ tresize(int col, int row)
304 term.dirty = xrealloc(term.dirty, row * sizeof(*term.dirty));
305 term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs));
306
307+ for (i = 0; i < HISTSIZE; i++) {
308+ term.hist[i] = xrealloc(term.hist[i], col * sizeof(Glyph));
309+ for (j = mincol; j < col; j++) {
310+ term.hist[i][j] = term.c.attr;
311+ term.hist[i][j].u = ' ';
312+ }
313+ }
314+
315 /* resize each row to new width, zero-pad if needed */
316 for (i = 0; i < minrow; i++) {
317 term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph));
318@@ -2577,7 +2647,7 @@ drawregion(int x1, int y1, int x2, int y2)
319 continue;
320
321 term.dirty[y] = 0;
322- xdrawline(term.line[y], x1, y, x2);
323+ xdrawline(TLINE(y), x1, y, x2);
324 }
325 }
326
327@@ -2598,8 +2668,9 @@ draw(void)
328 cx--;
329
330 drawregion(0, 0, term.col, term.row);
331- xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
332- term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
333+ if (term.scr == 0)
334+ xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
335+ term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
336 term.ocx = cx;
337 term.ocy = term.c.y;
338 xfinishdraw();
339diff --git a/st.h b/st.h
340index d978458..b9a4eeb 100644
341--- a/st.h
342+++ b/st.h
343@@ -81,6 +81,8 @@ void die(const char *, ...);
344 void redraw(void);
345 void draw(void);
346
347+void kscrolldown(const Arg *);
348+void kscrollup(const Arg *);
349 void printscreen(const Arg *);
350 void printsel(const Arg *);
351 void sendbreak(const Arg *);
diff --git a/st/patches/st-scrollback-mouse-20191024-a2c479c.diff b/st/patches/st-scrollback-mouse-20191024-a2c479c.diff
new file mode 100644
index 0000000..49eba8e
--- /dev/null
+++ b/st/patches/st-scrollback-mouse-20191024-a2c479c.diff
@@ -0,0 +1,13 @@
1diff --git a/config.def.h b/config.def.h
2index ec1b576..4b3bf15 100644
3--- a/config.def.h
4+++ b/config.def.h
5@@ -163,6 +163,8 @@ static uint forcemousemod = ShiftMask;
6 */
7 static MouseShortcut mshortcuts[] = {
8 /* mask button function argument release */
9+ { ShiftMask, Button4, kscrollup, {.i = 1} },
10+ { ShiftMask, Button5, kscrolldown, {.i = 1} },
11 { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
12 { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
13 { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
diff --git a/st/patches/st-scrollback-mouse-altscreen-20200416-5703aa0.diff b/st/patches/st-scrollback-mouse-altscreen-20200416-5703aa0.diff
new file mode 100644
index 0000000..fbade29
--- /dev/null
+++ b/st/patches/st-scrollback-mouse-altscreen-20200416-5703aa0.diff
@@ -0,0 +1,63 @@
1diff --git a/config.def.h b/config.def.h
2index 4b3bf15..1986316 100644
3--- a/config.def.h
4+++ b/config.def.h
5@@ -163,8 +163,8 @@ static uint forcemousemod = ShiftMask;
6 */
7 static MouseShortcut mshortcuts[] = {
8 /* mask button function argument release */
9- { ShiftMask, Button4, kscrollup, {.i = 1} },
10- { ShiftMask, Button5, kscrolldown, {.i = 1} },
11+ { XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, /* !alt */ -1 },
12+ { XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, /* !alt */ -1 },
13 { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
14 { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
15 { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
16diff --git a/st.c b/st.c
17index f8b6f67..dd4cb31 100644
18--- st.c
19+++ st.c
20@@ -1045,6 +1045,11 @@ tnew(int col, int row)
21 treset();
22 }
23
24+int tisaltscr(void)
25+{
26+ return IS_SET(MODE_ALTSCREEN);
27+}
28+
29 void
30 tswapscreen(void)
31 {
32diff --git a/st.h b/st.h
33index 1332cf1..f9ad815 100644
34--- st.h
35+++ st.h
36@@ -89,6 +89,7 @@ void sendbreak(const Arg *);
37 void toggleprinter(const Arg *);
38
39 int tattrset(int);
40+int tisaltscr(void);
41 void tnew(int, int);
42 void tresize(int, int);
43 void tsetdirtattr(int);
44diff --git a/x.c b/x.c
45index e5f1737..b8fbd7b 100644
46--- x.c
47+++ x.c
48@@ -34,6 +34,7 @@ typedef struct {
49 void (*func)(const Arg *);
50 const Arg arg;
51 uint release;
52+ int altscrn; /* 0: don't care, -1: not alt screen, 1: alt screen */
53 } MouseShortcut;
54
55 typedef struct {
56@@ -446,6 +447,7 @@ mouseaction(XEvent *e, uint release)
57 for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
58 if (ms->release == release &&
59 ms->button == e->xbutton.button &&
60+ (!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) &&
61 (match(ms->mod, state) || /* exact or forced */
62 match(ms->mod, state & ~forcemousemod))) {
63 ms->func(&(ms->arg));
diff --git a/st/patches/st-vertcenter-20180320-6ac8c8a.diff b/st/patches/st-vertcenter-20180320-6ac8c8a.diff
new file mode 100644
index 0000000..61f5c25
--- /dev/null
+++ b/st/patches/st-vertcenter-20180320-6ac8c8a.diff
@@ -0,0 +1,51 @@
1--- a/x.c Tue Mar 20 00:28:57 2018
2+++ b/x.c Tue Mar 20 00:29:02 2018
3@@ -80,6 +80,7 @@
4 int w, h; /* window width and height */
5 int ch; /* char height */
6 int cw; /* char width */
7+ int cyo; /* char y offset */
8 int mode; /* window state/mode flags */
9 int cursor; /* cursor style */
10 } TermWindow;
11@@ -949,6 +950,7 @@
12 /* Setting character width and height. */
13 win.cw = ceilf(dc.font.width * cwscale);
14 win.ch = ceilf(dc.font.height * chscale);
15+ win.cyo = ceilf(dc.font.height * (chscale - 1) / 2);
16
17 FcPatternDel(pattern, FC_SLANT);
18 FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
19@@ -1130,7 +1132,7 @@
20 FcCharSet *fccharset;
21 int i, f, numspecs = 0;
22
23- for (i = 0, xp = winx, yp = winy + font->ascent; i < len; ++i) {
24+ for (i = 0, xp = winx, yp = winy + font->ascent + win.cyo; i < len; ++i) {
25 /* Fetch rune and mode for current glyph. */
26 rune = glyphs[i].u;
27 mode = glyphs[i].mode;
28@@ -1155,7 +1157,7 @@
29 font = &dc.bfont;
30 frcflags = FRC_BOLD;
31 }
32- yp = winy + font->ascent;
33+ yp = winy + font->ascent + win.cyo;
34 }
35
36 /* Lookup character index with default font. */
37@@ -1371,12 +1373,12 @@
38
39 /* Render underline and strikethrough. */
40 if (base.mode & ATTR_UNDERLINE) {
41- XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1,
42+ XftDrawRect(xw.draw, fg, winx, winy + win.cyo + dc.font.ascent + 1,
43 width, 1);
44 }
45
46 if (base.mode & ATTR_STRUCK) {
47- XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3,
48+ XftDrawRect(xw.draw, fg, winx, winy + win.cyo + 2 * dc.font.ascent / 3,
49 width, 1);
50 }
51