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