summaryrefslogtreecommitdiff
path: root/st
diff options
context:
space:
mode:
Diffstat (limited to 'st')
-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
7 files changed, 1148 insertions, 0 deletions
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