aboutsummarylogtreecommitdiffstats
path: root/st.c
diff options
context:
space:
mode:
authorChristoph Lohmann2013-04-28 17:42:30 +0200
committerChristoph Lohmann2013-04-28 17:42:30 +0200
commit5a576b638411ecc469f3ffcf52b0a4c0b03e574a (patch)
tree50563ffea3339ca7645b9591e52e158259b75ce1 /st.c
parent445d9980058941a83351c0f1042d198e27ce2dd1 (diff)
downloadaur-5a576b638411ecc469f3ffcf52b0a4c0b03e574a.tar.gz
Add a possibility to modify the string sent by mouse buttons.
Thanks Alexander Rezinsky <alexrez@gmail.com> for the suggestion!
Diffstat (limited to 'st.c')
-rw-r--r--st.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/st.c b/st.c
index 07940d2475f1..aa2cd085eec3 100644
--- a/st.c
+++ b/st.c
@@ -229,6 +229,12 @@ typedef struct {
} 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 @@ mousereport(XEvent *e) {
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 @@ bpress(XEvent *e) {
}
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);
}
}