> * Ivan Tham <ivanthamjun...@gmail.com> [2015-05-26 17:47]: > > Thanks, I can get it to work now. Is there any way use the scrollback > > with mouse scroll? > On Tue, May 26, 2015 at 01:04:32PM +0200, Jochen Sprickerhof wrote: > Write a patch.
Not to do the work for him, but it so happens that I do have such a patch already.
From d7ec646572ee60c797547d1ea1dd4b89cc74d45a Mon Sep 17 00:00:00 2001 From: Alex Pilon <a...@alexpilon.ca> Date: Fri, 27 Mar 2015 22:42:11 -0400 Subject: [PATCH] Bind Shift-Mousewheel to scrollback buffer up/down. --- config.def.h | 12 +++++++++--- st.c | 17 ++++++++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index a977863..f4b716a 100644 --- a/config.def.h +++ b/config.def.h @@ -110,10 +110,16 @@ static const unsigned int defaultunderline = 258; /* Internal mouse shortcuts. */ /* Beware that overloading Button1 will disable the selection. */ -static Mousekey mshortcuts[] = { +static Mousekey mkeys[] = { /* button mask string */ - { Button4, XK_ANY_MOD, "\031" }, - { Button5, XK_ANY_MOD, "\005" }, + { Button4, XK_NO_MOD, "\031" }, + { Button5, XK_NO_MOD, "\005" }, +}; + +static MouseShortcut mshortcuts[] = { + /* button mask function argument */ + { Button4, ShiftMask, kscrollup, { .i = 1 } }, + { Button5, ShiftMask, kscrolldown, { .i = 1 } }, }; /* Internal keyboard shortcuts. */ diff --git a/st.c b/st.c index 8b98521..29828c8 100644 --- a/st.c +++ b/st.c @@ -323,6 +323,13 @@ typedef union { } Arg; typedef struct { + uint b; + uint mask; + void (*func)(const Arg *); + const Arg arg; +} MouseShortcut; + +typedef struct { uint mod; KeySym keysym; void (*func)(const Arg *); @@ -907,19 +914,27 @@ void bpress(XEvent *e) { struct timespec now; Mousekey *mk; + MouseShortcut *ms; if(IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { mousereport(e); return; } - for(mk = mshortcuts; mk < mshortcuts + LEN(mshortcuts); mk++) { + for(mk = mkeys; mk < mkeys + LEN(mkeys); mk++) { if(e->xbutton.button == mk->b && match(mk->mask, e->xbutton.state)) { ttysend(mk->s, strlen(mk->s)); return; } } + for(ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { + if(e->xbutton.button == ms->b + && match(ms->mask, e->xbutton.state)) { + ms->func(&ms->arg); + return; + } + } if(e->xbutton.button == Button1) { clock_gettime(CLOCK_MONOTONIC, &now); -- 2.4.1
pgpWxq2BO3P7I.pgp
Description: PGP signature