diff options
author | Malfurious <m@lfurio.us> | 2020-06-26 19:55:41 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2024-08-12 13:16:51 -0400 |
commit | a093db04b4650e3286f0eff01a4dda04d7c1ff5a (patch) | |
tree | 9331364378364fc6784691688139c9ef30baf54a | |
parent | efcbd7cb7cef5b418212fb6e6cf2e39860facfbb (diff) | |
download | st-a093db04b4650e3286f0eff01a4dda04d7c1ff5a.tar.gz st-a093db04b4650e3286f0eff01a4dda04d7c1ff5a.zip |
patch: scrollback-mouse-altscreen
Apply the following patch on top of the previous two to allow scrollback
using mouse wheel only when not in MODE_ALTSCREEN. For example the
content is being scrolled instead of the scrollback buffer in less.
Consequently the Shift modifier for scrolling is not needed anymore.
The mouse and altscreen patches 20191024-a2c479c (and later, including
this one) are simpler and more robust because st gained better support
for customized mouse shortcuts. As a result, the altscreen patch doesn't
really need the mouse patch. However to keep it simple the instructions
stay the same: the alrscreen patch still applies on top of the (now very
minimal) mouse patch.
-rw-r--r-- | config.def.h | 4 | ||||
-rw-r--r-- | st.c | 5 | ||||
-rw-r--r-- | st.h | 1 | ||||
-rw-r--r-- | x.c | 2 |
4 files changed, 10 insertions, 2 deletions
diff --git a/config.def.h b/config.def.h index 1b59ded..0c8447c 100644 --- a/config.def.h +++ b/config.def.h @@ -179,8 +179,8 @@ static uint forcemousemod = ShiftMask; */ static MouseShortcut mshortcuts[] = { /* mask button function argument release */ - { ShiftMask, Button4, kscrollup, {.i = 1} }, - { ShiftMask, Button5, kscrolldown, {.i = 1} }, + { XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, /* !alt */ -1 }, + { XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, /* !alt */ -1 }, { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} }, { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} }, @@ -1055,6 +1055,11 @@ tnew(int col, int row) treset(); } +int tisaltscr(void) +{ + return IS_SET(MODE_ALTSCREEN); +} + void tswapscreen(void) { @@ -90,6 +90,7 @@ void sendbreak(const Arg *); void toggleprinter(const Arg *); int tattrset(int); +int tisaltscr(void); void tnew(int, int); void tresize(int, int); void tsetdirtattr(int); @@ -34,6 +34,7 @@ typedef struct { void (*func)(const Arg *); const Arg arg; uint release; + int altscrn; /* 0: don't care, -1: not alt screen, 1: alt screen */ } MouseShortcut; typedef struct { @@ -463,6 +464,7 @@ mouseaction(XEvent *e, uint release) for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { if (ms->release == release && ms->button == e->xbutton.button && + (!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) && (match(ms->mod, state) || /* exact or forced */ match(ms->mod, state & ~forcemousemod))) { ms->func(&(ms->arg)); |