st

Simple Terminal by suckless.org (fork)
git clone git://git.ckyln.com/st.git
Log | Files | Refs | README | LICENSE

commit e590e816656b5d1d4f0c1ff804bf26aaabab3626
parent 61f3dc35b2db04682f2f494d6d60f11d2f404381
Author: Cem Keylan <cem@ckyln.com>
Date:   Tue, 12 Nov 2019 06:08:35 +0300

mouse shortcuts: allow same functions as kb shortcuts

Diffstat:
Mconfig.h | 6+++---
Mst.h | 1+
Mx.c | 20++++++++++++++------
3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/config.h b/config.h @@ -192,9 +192,9 @@ ResourcePref resources[] = { * Beware that overloading Button1 will disable the selection. */ static MouseShortcut mshortcuts[] = { - /* button mask string */ - { Button4, XK_ANY_MOD, "\031" }, - { Button5, XK_ANY_MOD, "\005" }, + /* mask button function argument */ + { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} }, + { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} }, }; static char *stdoutedit[] = { "/bin/sh", "-c", "editstdout" }; diff --git a/st.h b/st.h @@ -74,6 +74,7 @@ typedef union { uint ui; float f; const void *v; + const char *s; } Arg; void die(const char *, ...); diff --git a/x.c b/x.c @@ -30,9 +30,10 @@ typedef struct { } Shortcut; typedef struct { - uint b; - uint mask; - char *s; + uint mod; + uint button; + void (*func)(const Arg *); + const Arg arg; } MouseShortcut; typedef struct { @@ -70,6 +71,7 @@ static void selpaste(const Arg *); static void zoom(const Arg *); static void zoomabs(const Arg *); static void zoomreset(const Arg *); +static void ttysend(const Arg *); /* config.h for applying patches and the configuration. */ #include "config.h" @@ -328,6 +330,12 @@ zoomreset(const Arg *arg) } } +void +ttysend(const Arg *arg) +{ + ttywrite(arg->s, strlen(arg->s), 1); +} + int evcol(XEvent *e) { @@ -437,9 +445,9 @@ bpress(XEvent *e) } for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) { - if (e->xbutton.button == ms->b - && match(ms->mask, e->xbutton.state)) { - ttywrite(ms->s, strlen(ms->s), 1); + if (e->xbutton.button == ms->button + && match(ms->mod, e->xbutton.state)) { + ms->func(&(ms->arg)); return; } }