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