diff options
| -rw-r--r-- | config.def.h | 10 | ||||
| -rw-r--r-- | st.c | 26 |
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; | |||
| 74 | static unsigned int defaultitalic = 11; | 74 | static unsigned int defaultitalic = 11; |
| 75 | static unsigned int defaultunderline = 7; | 75 | static unsigned int defaultunderline = 7; |
| 76 | 76 | ||
| 77 | /* Internal shortcuts. */ | 77 | /* Internal mouse shortcuts. */ |
| 78 | /* Beware that overloading Button1 will disable the selection. */ | ||
| 79 | static 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 | ||
| 80 | static Shortcut shortcuts[] = { | 88 | static Shortcut shortcuts[] = { |
| @@ -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 | ||
