all repos — dotfiles @ a23a4945b23420b1b0800e9e3dfe9bfc083f1968

my *nix dotfiles

st/patches/st-scrollback-mouse-altscreen-20191024-a2c479c.diff (view raw)

 1diff --git a/config.def.h b/config.def.h
 2index 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"} },
16diff --git a/st.c b/st.c
17index 9a4f5a4..eb5bd86 100644
18--- a/st.c
19+++ b/st.c
20@@ -1040,6 +1040,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 {
32diff --git a/st.h b/st.h
33index 1332cf1..f9ad815 100644
34--- a/st.h
35+++ b/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);
44diff --git a/x.c b/x.c
45index 6406925..de41086 100644
46--- a/x.c
47+++ b/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@@ -426,6 +427,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, e->xbutton.state) ||  /* exact or forced */
62 		     match(ms->mod, e->xbutton.state & ~forcemousemod))) {
63 			ms->func(&(ms->arg));