st-scrollback-mouse-0.8.2.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
st-scrollback-mouse-0.8.2.diff (2181B)
---
1 From 315f69069017122ca69d0319d0ad9481113fe5c8 Mon Sep 17 00:00:00 2001
2 From: Jacob Prosser <jacoblouisprosser@protonmail.com>
3 Date: Fri, 26 Apr 2019 17:23:27 +1000
4 Subject: [PATCH] Scrollback-Mouse for 0.8.2
5
6 ---
7 config.def.h | 10 ++++++++--
8 st.h | 8 ++++++++
9 x.c | 9 +++++++++
10 3 files changed, 25 insertions(+), 2 deletions(-)
11
12 diff --git a/config.def.h b/config.def.h
13 index 7326a74..ad20c4c 100644
14 --- a/config.def.h
15 +++ b/config.def.h
16 @@ -156,8 +156,14 @@ static unsigned int defaultattr = 11;
17 */
18 static MouseShortcut mshortcuts[] = {
19 /* button mask string */
20 - { Button4, XK_ANY_MOD, "\031" },
21 - { Button5, XK_ANY_MOD, "\005" },
22 + { Button4, XK_NO_MOD, "\031" },
23 + { Button5, XK_NO_MOD, "\005" },
24 +};
25 +
26 +MouseKey mkeys[] = {
27 + /* button mask function argument */
28 + { Button4, ShiftMask, kscrollup, {.i = 1} },
29 + { Button5, ShiftMask, kscrolldown, {.i = 1} },
30 };
31
32 /* Internal keyboard shortcuts. */
33 diff --git a/st.h b/st.h
34 index 17a79e0..3ac7f57 100644
35 --- a/st.h
36 +++ b/st.h
37 @@ -76,6 +76,13 @@ typedef union {
38 const void *v;
39 } Arg;
40
41 +typedef struct {
42 + uint b;
43 + uint mask;
44 + void (*func)(const Arg *);
45 + const Arg arg;
46 +} MouseKey;
47 +
48 void die(const char *, ...);
49 void redraw(void);
50 void draw(void);
51 @@ -122,3 +129,4 @@ extern char *termname;
52 extern unsigned int tabspaces;
53 extern unsigned int defaultfg;
54 extern unsigned int defaultbg;
55 +extern MouseKey mkeys[];
56 diff --git a/x.c b/x.c
57 index 0422421..e9fd6e9 100644
58 --- a/x.c
59 +++ b/x.c
60 @@ -409,6 +409,7 @@ bpress(XEvent *e)
61 {
62 struct timespec now;
63 MouseShortcut *ms;
64 + MouseKey *mk;
65 int snap;
66
67 if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
68 @@ -424,6 +425,14 @@ bpress(XEvent *e)
69 }
70 }
71
72 + for (mk = mkeys; mk < mkeys + LEN(mkeys); mk++) {
73 + if (e->xbutton.button == mk->b
74 + && match(mk->mask, e->xbutton.state)) {
75 + mk->func(&mk->arg);
76 + return;
77 + }
78 + }
79 +
80 if (e->xbutton.button == Button1) {
81 /*
82 * If the user clicks below predefined timeouts specific
83 --
84 2.21.0
85