all repos — st @ a53017c8b47f511cf0462ac910cf9223a31ceb2f

st (suckless terminal) config

Add a possibility to modify the string sent by mouse buttons.

Thanks Alexander Rezinsky <alexrez@gmail.com> for the suggestion!
Christoph Lohmann 20h@r-36.net
commit

a53017c8b47f511cf0462ac910cf9223a31ceb2f

parent

a77b01176a34de741485024e5e36002cff3c1124

2 files changed, 30 insertions(+), 6 deletions(-)

jump to
M config.def.hconfig.def.h

@@ -74,7 +74,15 @@ */

static unsigned int defaultitalic = 11; static unsigned int defaultunderline = 7; -/* Internal shortcuts. */ +/* Internal mouse shortcuts. */ +/* Beware that overloading Button1 will disable the selection. */ +static Mousekey mshortcuts[] = { + /* keysym mask string */ + { Button4, XK_ANY_MOD, "\031"}, + { Button5, XK_ANY_MOD, "\005"}, +}; + +/* Internal keyboard shortcuts. */ #define MODKEY Mod1Mask static Shortcut shortcuts[] = {
M st.cst.c

@@ -229,6 +229,12 @@ char state; /* focus, redraw, visible */

} XWindow; typedef struct { + int b; + uint mask; + char s[ESC_BUF_SIZ]; +} Mousekey; + +typedef struct { KeySym k; uint mask; char s[ESC_BUF_SIZ];

@@ -771,10 +777,24 @@

void bpress(XEvent *e) { struct timeval now; + Mousekey *mk; if(IS_SET(MODE_MOUSE)) { mousereport(e); - } else if(e->xbutton.button == Button1) { + return; + } + + for(mk = mshortcuts; mk < mshortcuts + LEN(mshortcuts); mk++) { + if(e->xbutton.button == mk->b + && match(mk->mask, e->xbutton.state)) { + ttywrite(mk->s, strlen(mk->s)); + if(IS_SET(MODE_ECHO)) + techo(mk->s, strlen(mk->s)); + return; + } + } + + if(e->xbutton.button == Button1) { gettimeofday(&now, NULL); /* Clear previous selection, logically and visually. */

@@ -817,10 +837,6 @@ draw();

} sel.tclick2 = sel.tclick1; sel.tclick1 = now; - } else if(e->xbutton.button == Button4) { - ttywrite("\031", 1); - } else if(e->xbutton.button == Button5) { - ttywrite("\005", 1); } }