sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

st-universcroll-0.8.4.diff (2954B)


      1 From 9726b1e58352126252412e101432e64d46fc51ca Mon Sep 17 00:00:00 2001
      2 From: Dennis Lee <dennis@dennislee.xyz>
      3 Date: Sun, 28 Jun 2020 23:01:03 -0700
      4 Subject: [PATCH] universcroll: mouse wheel only scroll in all modes
      5 
      6 Scroll normally via scroll(1), without Shift, when outside of
      7 `MODE_ALTSCREEN`. Inside an alt screen, continue to scroll normally
      8 without Shift; in this mode, your scrolling is automatically translated
      9 into ^Y and ^E. It just werks!
     10 
     11 Based on the existing mouse-altscreen patch
     12 https://st.suckless.org/patches/scrollback/
     13 adapted for st(1) 0.8.4 and scroll(1).
     14 ---
     15  config.def.h | 10 +++++-----
     16  st.c         |  5 +++++
     17  st.h         |  1 +
     18  x.c          |  2 ++
     19  4 files changed, 13 insertions(+), 5 deletions(-)
     20 
     21 diff --git a/config.def.h b/config.def.h
     22 index 6f05dce..62e87da 100644
     23 --- a/config.def.h
     24 +++ b/config.def.h
     25 @@ -173,11 +173,11 @@ static uint forcemousemod = ShiftMask;
     26   * Beware that overloading Button1 will disable the selection.
     27   */
     28  static MouseShortcut mshortcuts[] = {
     29 -	/* mask                 button   function        argument       release */
     30 -	{ XK_ANY_MOD,           Button2, selpaste,       {.i = 0},      1 },
     31 -	{ ShiftMask,            Button4, ttysend,        {.s = "\033[5;2~"} },
     32 +	/* mask                 button   function        argument      release alt */
     33 +	{ XK_ANY_MOD,           Button2, selpaste,       {.i = 0},           1 },
     34 +	{ XK_ANY_MOD,           Button4, ttysend,        {.s = "\033[5;2~"}, 0, -1 },
     35  	{ XK_ANY_MOD,           Button4, ttysend,        {.s = "\031"} },
     36 -	{ ShiftMask,            Button5, ttysend,        {.s = "\033[6;2~"} },
     37 +	{ XK_ANY_MOD,           Button5, ttysend,        {.s = "\033[6;2~"}, 0, -1 },
     38  	{ XK_ANY_MOD,           Button5, ttysend,        {.s = "\005"} },
     39  };
     40 
     41 diff --git a/st.c b/st.c
     42 index 76b7e0d..1f65453 100644
     43 --- a/st.c
     44 +++ b/st.c
     45 @@ -1047,6 +1047,11 @@ tnew(int col, int row)
     46  	treset();
     47  }
     48 
     49 +int tisaltscr(void)
     50 +{
     51 +	return IS_SET(MODE_ALTSCREEN);
     52 +}
     53 +
     54  void
     55  tswapscreen(void)
     56  {
     57 diff --git a/st.h b/st.h
     58 index 3d351b6..39cc054 100644
     59 --- a/st.h
     60 +++ b/st.h
     61 @@ -87,6 +87,7 @@ void sendbreak(const Arg *);
     62  void toggleprinter(const Arg *);
     63 
     64  int tattrset(int);
     65 +int tisaltscr(void);
     66  void tnew(int, int);
     67  void tresize(int, int);
     68  void tsetdirtattr(int);
     69 diff --git a/x.c b/x.c
     70 index 210f184..210dde9 100644
     71 --- a/x.c
     72 +++ b/x.c
     73 @@ -34,6 +34,7 @@ typedef struct {
     74  	void (*func)(const Arg *);
     75  	const Arg arg;
     76  	uint  release;
     77 +	int  altscrn;  /* 0: don't care, -1: not alt screen, 1: alt screen */
     78  } MouseShortcut;
     79 
     80  typedef struct {
     81 @@ -446,6 +447,7 @@ mouseaction(XEvent *e, uint release)
     82  	for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
     83  		if (ms->release == release &&
     84  		    ms->button == e->xbutton.button &&
     85 +		    (!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) &&
     86  		    (match(ms->mod, state) ||  /* exact or forced */
     87  		     match(ms->mod, state & ~forcemousemod))) {
     88  			ms->func(&(ms->arg));
     89 --
     90 2.27.0