aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2013-04-28 17:42:30 +0200
committerChristoph Lohmann <20h@r-36.net>2013-04-28 17:42:30 +0200
commita53017c8b47f511cf0462ac910cf9223a31ceb2f (patch)
tree711c8eca1a8079229e15c3c3bb45353b1b0dc658
parenta77b01176a34de741485024e5e36002cff3c1124 (diff)
downloadst-patched-a53017c8b47f511cf0462ac910cf9223a31ceb2f.tar.bz2
st-patched-a53017c8b47f511cf0462ac910cf9223a31ceb2f.tar.xz
st-patched-a53017c8b47f511cf0462ac910cf9223a31ceb2f.zip
Add a possibility to modify the string sent by mouse buttons.
Thanks Alexander Rezinsky <alexrez@gmail.com> for the suggestion!
-rw-r--r--config.def.h10
-rw-r--r--st.c26
2 files changed, 30 insertions, 6 deletions
diff --git a/config.def.h b/config.def.h
index b44fe17..b0bc752 100644
--- a/config.def.h
+++ b/config.def.h
@@ -74,7 +74,15 @@ static unsigned int defaultcs = 256;
74static unsigned int defaultitalic = 11; 74static unsigned int defaultitalic = 11;
75static unsigned int defaultunderline = 7; 75static unsigned int defaultunderline = 7;
76 76
77/* Internal shortcuts. */ 77/* Internal mouse shortcuts. */
78/* Beware that overloading Button1 will disable the selection. */
79static Mousekey mshortcuts[] = {
80 /* keysym mask string */
81 { Button4, XK_ANY_MOD, "\031"},
82 { Button5, XK_ANY_MOD, "\005"},
83};
84
85/* Internal keyboard shortcuts. */
78#define MODKEY Mod1Mask 86#define MODKEY Mod1Mask
79 87
80static Shortcut shortcuts[] = { 88static Shortcut shortcuts[] = {
diff --git a/st.c b/st.c
index 07940d2..aa2cd08 100644
--- a/st.c
+++ b/st.c
@@ -229,6 +229,12 @@ typedef struct {
229} XWindow; 229} XWindow;
230 230
231typedef struct { 231typedef struct {
232 int b;
233 uint mask;
234 char s[ESC_BUF_SIZ];
235} Mousekey;
236
237typedef struct {
232 KeySym k; 238 KeySym k;
233 uint mask; 239 uint mask;
234 char s[ESC_BUF_SIZ]; 240 char s[ESC_BUF_SIZ];
@@ -771,10 +777,24 @@ mousereport(XEvent *e) {
771void 777void
772bpress(XEvent *e) { 778bpress(XEvent *e) {
773 struct timeval now; 779 struct timeval now;
780 Mousekey *mk;
774 781
775 if(IS_SET(MODE_MOUSE)) { 782 if(IS_SET(MODE_MOUSE)) {
776 mousereport(e); 783 mousereport(e);
777 } else if(e->xbutton.button == Button1) { 784 return;
785 }
786
787 for(mk = mshortcuts; mk < mshortcuts + LEN(mshortcuts); mk++) {
788 if(e->xbutton.button == mk->b
789 && match(mk->mask, e->xbutton.state)) {
790 ttywrite(mk->s, strlen(mk->s));
791 if(IS_SET(MODE_ECHO))
792 techo(mk->s, strlen(mk->s));
793 return;
794 }
795 }
796
797 if(e->xbutton.button == Button1) {
778 gettimeofday(&now, NULL); 798 gettimeofday(&now, NULL);
779 799
780 /* Clear previous selection, logically and visually. */ 800 /* Clear previous selection, logically and visually. */
@@ -817,10 +837,6 @@ bpress(XEvent *e) {
817 } 837 }
818 sel.tclick2 = sel.tclick1; 838 sel.tclick2 = sel.tclick1;
819 sel.tclick1 = now; 839 sel.tclick1 = now;
820 } else if(e->xbutton.button == Button4) {
821 ttywrite("\031", 1);
822 } else if(e->xbutton.button == Button5) {
823 ttywrite("\005", 1);
824 } 840 }
825} 841}
826 842