diff options
author | Christoph Lohmann <20h@r-36.net> | 2013-04-28 17:42:30 +0200 |
---|---|---|
committer | Christoph Lohmann <20h@r-36.net> | 2013-04-28 17:42:30 +0200 |
commit | a53017c8b47f511cf0462ac910cf9223a31ceb2f (patch) | |
tree | 711c8eca1a8079229e15c3c3bb45353b1b0dc658 /st.c | |
parent | a77b01176a34de741485024e5e36002cff3c1124 (diff) | |
download | st-a53017c8b47f511cf0462ac910cf9223a31ceb2f.tar.gz st-a53017c8b47f511cf0462ac910cf9223a31ceb2f.zip |
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.c | 26 |
1 files changed, 21 insertions, 5 deletions
@@ -229,6 +229,12 @@ typedef struct { | |||
229 | } XWindow; | 229 | } XWindow; |
230 | 230 | ||
231 | typedef struct { | 231 | typedef struct { |
232 | int b; | ||
233 | uint mask; | ||
234 | char s[ESC_BUF_SIZ]; | ||
235 | } Mousekey; | ||
236 | |||
237 | typedef 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) { | |||
771 | void | 777 | void |
772 | bpress(XEvent *e) { | 778 | bpress(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 | ||