[wiki] [sites] [st][PATCH] universcroll: altscreen detect/binds || Dennis Lee

From: <git_AT_suckless.org>
Date: Tue, 30 Jun 2020 07:22:27 +0200

commit 813c2138977ec6b9edd42364859937eadf9ff272
Author: Dennis Lee <dennis_AT_dennislee.xyz>
Date: Mon Jun 29 22:19:37 2020 -0700

    [st][PATCH] universcroll: altscreen detect/binds

diff --git a/st.suckless.org/patches/universcroll/index.md b/st.suckless.org/patches/universcroll/index.md
new file mode 100644
index 00000000..a285343d
--- /dev/null
+++ b/st.suckless.org/patches/universcroll/index.md
_AT_@ -0,0 +1,32 @@
+universcroll
+============
+
+Description
+-----------
+With *scroll*(1) and default binds (as of 0.8.4), how to scroll?
+- Inside alt screen? Mouse[4,5] to scroll [Up,Down]. :)
+- Outside alt screen? Shift+Mouse[4,5] to scroll [Up,Down]. :(
+
+With universcroll patch, always use Mouse[4,5] to scroll [Up,Down].
+Doesn't matter alt screen or not. No more `^Y^Y^Y^Y^Y^E^E^E^E^E`!
+
+`universcroll-example` on top of `universcroll` makes some extra
+changes:
+- Set scroll program = "scroll"
+- Mouse wheel scroll enabled only with NO_MOD.
+- Mouse wheel zoom enabled with ShiftMask/ANY_MOD.
+
+Download
+--------
+- [st-universcroll-0.8.4.diff](st-universcroll-0.8.4.diff)
+- [st-universcroll-example-0.8.4.diff](st-universcroll-example-0.8.4.diff)
+
+Notes
+-----
+`universcroll` was made possible by
+[scrollback-mouse-altscreen](https://st.suckless.org/patches/scrollback/).
+All alt screen detection code is from that patch.
+
+Author
+------
+- [Dennis Lee](%6D%61%69%6C%74%6F%3A%44%65%6E%6E%69%73%40%44%65%6E%6E%69%73%4C%65%65%2E%78%79%7A)
diff --git a/st.suckless.org/patches/universcroll/st-universcroll-0.8.4.diff b/st.suckless.org/patches/universcroll/st-universcroll-0.8.4.diff
new file mode 100644
index 00000000..6a33813b
--- /dev/null
+++ b/st.suckless.org/patches/universcroll/st-universcroll-0.8.4.diff
_AT_@ -0,0 +1,90 @@
+From 9726b1e58352126252412e101432e64d46fc51ca Mon Sep 17 00:00:00 2001
+From: Dennis Lee <dennis_AT_dennislee.xyz>
+Date: Sun, 28 Jun 2020 23:01:03 -0700
+Subject: [PATCH] universcroll: mouse wheel only scroll in all modes
+
+Scroll normally via scroll(1), without Shift, when outside of
+`MODE_ALTSCREEN`. Inside an alt screen, continue to scroll normally
+without Shift; in this mode, your scrolling is automatically translated
+into ^Y and ^E. It just werks!
+
+Based on the existing mouse-altscreen patch
+https://st.suckless.org/patches/scrollback/
+adapted for st(1) 0.8.4 and scroll(1).
+---
+ config.def.h | 10 +++++-----
+ st.c | 5 +++++
+ st.h | 1 +
+ x.c | 2 ++
+ 4 files changed, 13 insertions(+), 5 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 6f05dce..62e87da 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -173,11 +173,11 @@ static uint forcemousemod = ShiftMask;
+ * Beware that overloading Button1 will disable the selection.
+ */
+ static MouseShortcut mshortcuts[] = {
+- /* mask button function argument release */
+- { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
+- { ShiftMask, Button4, ttysend, {.s = "[5;2~"} },
++ /* mask button function argument release alt */
++ { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
++ { XK_ANY_MOD, Button4, ttysend, {.s = "[5;2~"}, 0, -1 },
+ { XK_ANY_MOD, Button4, ttysend, {.s = ""} },
+- { ShiftMask, Button5, ttysend, {.s = "[6;2~"} },
++ { XK_ANY_MOD, Button5, ttysend, {.s = "[6;2~"}, 0, -1 },
+ { XK_ANY_MOD, Button5, ttysend, {.s = ""} },
+ };
+
+diff --git a/st.c b/st.c
+index 76b7e0d..1f65453 100644
+--- a/st.c
++++ b/st.c
+_AT_@ -1047,6 +1047,11 @@ tnew(int col, int row)
+ treset();
+ }
+
++int tisaltscr(void)
++{
++ return IS_SET(MODE_ALTSCREEN);
++}
++
+ void
+ tswapscreen(void)
+ {
+diff --git a/st.h b/st.h
+index 3d351b6..39cc054 100644
+--- a/st.h
++++ b/st.h
+_AT_@ -87,6 +87,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);
+diff --git a/x.c b/x.c
+index 210f184..210dde9 100644
+--- a/x.c
++++ b/x.c
+_AT_@ -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 {
+_AT_@ -446,6 +447,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));
+--
+2.27.0
diff --git a/st.suckless.org/patches/universcroll/st-universcroll-example-0.8.4.diff b/st.suckless.org/patches/universcroll/st-universcroll-example-0.8.4.diff
new file mode 100644
index 00000000..76ff70d3
--- /dev/null
+++ b/st.suckless.org/patches/universcroll/st-universcroll-example-0.8.4.diff
_AT_@ -0,0 +1,47 @@
+From 59d2c9b65f90f78507b88d773323aab31194b7b4 Mon Sep 17 00:00:00 2001
+From: Dennis Lee <dennis_AT_dennislee.xyz>
+Date: Mon, 29 Jun 2020 21:33:08 -0700
+Subject: [PATCH] universcroll: sane default configuration
+
+- Set scroll program = "scroll"
+- Mouse wheel scroll only with NO_MOD.
+- Mouse wheel zoom with ShiftMask/ANY_MOD.
+---
+ config.def.h | 14 +++++++++-----
+ 1 file changed, 9 insertions(+), 5 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index a52c0a2..74fd64c 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -19,7 +19,7 @@ static int borderpx = 2;
+ static char *shell = "/bin/sh";
+ char *utmp = NULL;
+ /* scroll program: to enable use a string like "scroll" */
+-char *scroll = NULL;
++char *scroll = "scroll";
+ char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
+
+ /* identification sequence returned in DA and DECID */
+_AT_@ -175,10 +175,14 @@ static uint forcemousemod = ShiftMask;
+ static MouseShortcut mshortcuts[] = {
+ /* mask button function argument release alt */
+ { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
+- { XK_ANY_MOD, Button4, ttysend, {.s = "[5;2~"}, 0, -1 },
+- { XK_ANY_MOD, Button4, ttysend, {.s = ""} },
+- { XK_ANY_MOD, Button5, ttysend, {.s = "[6;2~"}, 0, -1 },
+- { XK_ANY_MOD, Button5, ttysend, {.s = ""} },
++ { ShiftMask, Button4, zoom, {.f = +1} },
++ { ShiftMask, Button5, zoom, {.f = -1} },
++ { XK_NO_MOD, Button4, ttysend, {.s = "[5;2~"}, 0, -1 },
++ { XK_NO_MOD, Button4, ttysend, {.s = ""} },
++ { XK_NO_MOD, Button5, ttysend, {.s = "[6;2~"}, 0, -1 },
++ { XK_NO_MOD, Button5, ttysend, {.s = ""} },
++ { XK_ANY_MOD, Button4, zoom, {.f = +1} },
++ { XK_ANY_MOD, Button5, zoom, {.f = -1} },
+ };
+
+ /* Internal keyboard shortcuts. */
+--
+2.27.0
+
Received on Tue Jun 30 2020 - 07:22:27 CEST

This archive was generated by hypermail 2.3.0 : Tue Jun 30 2020 - 07:24:46 CEST