Adds scrollback with mouse patch

master
Jonathan Hodgson 5 years ago
parent 22d8cae029
commit e441259963
  1. 10
      config.def.h
  2. 8
      st.h
  3. 9
      x.c

@ -156,8 +156,14 @@ static unsigned int defaultattr = 11;
*/ */
static MouseShortcut mshortcuts[] = { static MouseShortcut mshortcuts[] = {
/* button mask string */ /* button mask string */
{ Button4, XK_ANY_MOD, "\031" }, { Button4, XK_NO_MOD, "\031" },
{ Button5, XK_ANY_MOD, "\005" }, { Button5, XK_NO_MOD, "\005" },
};
MouseKey mkeys[] = {
/* button mask function argument */
{ Button4, ShiftMask, kscrollup, {.i = 1} },
{ Button5, ShiftMask, kscrolldown, {.i = 1} },
}; };
/* Internal keyboard shortcuts. */ /* Internal keyboard shortcuts. */

@ -76,6 +76,13 @@ typedef union {
const void *v; const void *v;
} Arg; } Arg;
typedef struct {
uint b;
uint mask;
void (*func)(const Arg *);
const Arg arg;
} MouseKey;
void die(const char *, ...); void die(const char *, ...);
void redraw(void); void redraw(void);
void draw(void); void draw(void);
@ -122,3 +129,4 @@ extern char *termname;
extern unsigned int tabspaces; extern unsigned int tabspaces;
extern unsigned int defaultfg; extern unsigned int defaultfg;
extern unsigned int defaultbg; extern unsigned int defaultbg;
extern MouseKey mkeys[];

9
x.c

@ -413,6 +413,7 @@ bpress(XEvent *e)
{ {
struct timespec now; struct timespec now;
MouseShortcut *ms; MouseShortcut *ms;
MouseKey *mk;
int snap; int snap;
if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
@ -428,6 +429,14 @@ bpress(XEvent *e)
} }
} }
for (mk = mkeys; mk < mkeys + LEN(mkeys); mk++) {
if (e->xbutton.button == mk->b
&& match(mk->mask, e->xbutton.state)) {
mk->func(&mk->arg);
return;
}
}
if (e->xbutton.button == Button1) { if (e->xbutton.button == Button1) {
/* /*
* If the user clicks below predefined timeouts specific * If the user clicks below predefined timeouts specific

Loading…
Cancel
Save