st-scrollback-mouse-0.8.diff (1813B)
1 diff --git a/config.def.h b/config.def.h 2 index 27d42ca..feec7e2 100644 3 --- a/config.def.h 4 +++ b/config.def.h 5 @@ -156,8 +156,14 @@ static unsigned int defaultattr = 11; 6 */ 7 static MouseShortcut mshortcuts[] = { 8 /* button mask string */ 9 - { Button4, XK_ANY_MOD, "\031" }, 10 - { Button5, XK_ANY_MOD, "\005" }, 11 + { Button4, XK_NO_MOD, "\031" }, 12 + { Button5, XK_NO_MOD, "\005" }, 13 +}; 14 + 15 +MouseKey mkeys[] = { 16 + /* button mask function argument */ 17 + { Button4, ShiftMask, kscrollup, {.i = 1} }, 18 + { Button5, ShiftMask, kscrolldown, {.i = 1} }, 19 }; 20 21 /* Internal keyboard shortcuts. */ 22 diff --git a/st.h b/st.h 23 index 628e876..cdd25ae 100644 24 --- a/st.h 25 +++ b/st.h 26 @@ -81,6 +81,13 @@ typedef union { 27 const void *v; 28 } Arg; 29 30 +typedef struct { 31 + uint b; 32 + uint mask; 33 + void (*func)(const Arg *); 34 + const Arg arg; 35 +} MouseKey; 36 + 37 void die(const char *, ...); 38 void redraw(void); 39 void draw(void); 40 @@ -129,3 +136,4 @@ extern char *termname; 41 extern unsigned int tabspaces; 42 extern unsigned int defaultfg; 43 extern unsigned int defaultbg; 44 +extern MouseKey mkeys[]; 45 diff --git a/x.c b/x.c 46 index d43a529..754d859 100644 47 --- a/x.c 48 +++ b/x.c 49 @@ -409,6 +409,7 @@ bpress(XEvent *e) 50 { 51 struct timespec now; 52 MouseShortcut *ms; 53 + MouseKey *mk; 54 int snap; 55 56 if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { 57 @@ -424,6 +425,14 @@ bpress(XEvent *e) 58 } 59 } 60 61 + for (mk = mkeys; mk < mkeys + LEN(mkeys); mk++) { 62 + if (e->xbutton.button == mk->b 63 + && match(mk->mask, e->xbutton.state)) { 64 + mk->func(&mk->arg); 65 + return; 66 + } 67 + } 68 + 69 if (e->xbutton.button == Button1) { 70 /* 71 * If the user clicks below predefined timeouts specific