st-scrollback-mouse-altscreen-20200416-5703aa0.diff (1846B) - raw


      1 diff --git a/config.def.h b/config.def.h
      2 index 4b3bf15..1986316 100644
      3 --- a/config.def.h
      4 +++ b/config.def.h
      5 @@ -163,6 +163,8 @@ static uint forcemousemod = ShiftMask;
      6   */
      7  static MouseShortcut mshortcuts[] = {
      8  	/* mask                 button   function        argument       release */
      9 +	{ XK_ANY_MOD,           Button4, kscrollup,      {.i = 1},      0, /* !alt */ -1 },
     10 +	{ XK_ANY_MOD,           Button5, kscrolldown,    {.i = 1},      0, /* !alt */ -1 },
     11  	{ XK_ANY_MOD,           Button2, selpaste,       {.i = 0},      1 },
     12  	{ ShiftMask,            Button4, ttysend,        {.s = "\033[5;2~"} },
     13  	{ XK_ANY_MOD,           Button4, ttysend,        {.s = "\031"} },
     14 diff --git a/st.c b/st.c
     15 index f8b6f67..dd4cb31 100644
     16 --- st.c
     17 +++ st.c
     18 @@ -1045,6 +1045,11 @@ tnew(int col, int row)
     19  	treset();
     20  }
     21  
     22 +int tisaltscr(void)
     23 +{
     24 +	return IS_SET(MODE_ALTSCREEN);
     25 +}
     26 +
     27  void
     28  tswapscreen(void)
     29  {
     30 diff --git a/st.h b/st.h
     31 index 1332cf1..f9ad815 100644
     32 --- st.h
     33 +++ st.h
     34 @@ -89,6 +89,7 @@ void sendbreak(const Arg *);
     35  void toggleprinter(const Arg *);
     36  
     37  int tattrset(int);
     38 +int tisaltscr(void);
     39  void tnew(int, int);
     40  void tresize(int, int);
     41  void tsetdirtattr(int);
     42 diff --git a/x.c b/x.c
     43 index e5f1737..b8fbd7b 100644
     44 --- x.c
     45 +++ x.c
     46 @@ -34,6 +34,7 @@ typedef struct {
     47  	void (*func)(const Arg *);
     48  	const Arg arg;
     49  	uint  release;
     50 +	int  altscrn;  /* 0: don't care, -1: not alt screen, 1: alt screen */
     51  } MouseShortcut;
     52  
     53  typedef struct {
     54 @@ -446,6 +447,7 @@ mouseaction(XEvent *e, uint release)
     55  	for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
     56  		if (ms->release == release &&
     57  		    ms->button == e->xbutton.button &&
     58 +		    (!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) &&
     59  		    (match(ms->mod, state) ||  /* exact or forced */
     60  		     match(ms->mod, state & ~forcemousemod))) {
     61  			ms->func(&(ms->arg));