diff options
| author | Christoph Lohmann <20h@r-36.net> | 2013-04-25 06:28:11 +0200 |
|---|---|---|
| committer | Christoph Lohmann <20h@r-36.net> | 2013-04-25 06:28:11 +0200 |
| commit | 1b2751f5c24ca06afbb68e41e73fc9fce6c6b521 (patch) | |
| tree | 8734f7a2900ed8d5443df94671665f91d68cba33 | |
| parent | 0851f2be2ab48ee3a67ef2287c09bd67622dcd8e (diff) | |
| download | st-1b2751f5c24ca06afbb68e41e73fc9fce6c6b521.tar.gz st-1b2751f5c24ca06afbb68e41e73fc9fce6c6b521.zip | |
Fixing the selection handling to allow one char selection.
Thanks Alexander Sedov <alex0player@gmail.com> for suggesting the fix!
| -rw-r--r-- | st.c | 19 |
1 files changed, 9 insertions, 10 deletions
| @@ -785,11 +785,8 @@ bpress(XEvent *e) { | |||
| 785 | sel.ey = sel.by = y2row(e->xbutton.y); | 785 | sel.ey = sel.by = y2row(e->xbutton.y); |
| 786 | 786 | ||
| 787 | /* | 787 | /* |
| 788 | * Snap handling. | 788 | * If the user clicks below predefined timeouts specific |
| 789 | * If user clicks are fasst enough (e.g. below timeouts), | 789 | * snapping behaviour is exposed. |
| 790 | * we ignore if his hand slipped left or down and accidentally | ||
| 791 | * selected more; we are just snapping to whatever we're | ||
| 792 | * snapping. | ||
| 793 | */ | 790 | */ |
| 794 | if(TIMEDIFF(now, sel.tclick2) <= tripleclicktimeout) { | 791 | if(TIMEDIFF(now, sel.tclick2) <= tripleclicktimeout) { |
| 795 | sel.snap = SNAP_LINE; | 792 | sel.snap = SNAP_LINE; |
| @@ -809,7 +806,8 @@ bpress(XEvent *e) { | |||
| 809 | * Draw selection, unless it's regular and we don't want to | 806 | * Draw selection, unless it's regular and we don't want to |
| 810 | * make clicks visible | 807 | * make clicks visible |
| 811 | */ | 808 | */ |
| 812 | if (sel.snap != 0) { | 809 | if(sel.snap != 0) { |
| 810 | sel.mode++; | ||
| 813 | tsetdirt(sel.b.y, sel.e.y); | 811 | tsetdirt(sel.b.y, sel.e.y); |
| 814 | draw(); | 812 | draw(); |
| 815 | } | 813 | } |
| @@ -987,14 +985,14 @@ brelease(XEvent *e) { | |||
| 987 | if(e->xbutton.button == Button2) { | 985 | if(e->xbutton.button == Button2) { |
| 988 | selpaste(NULL); | 986 | selpaste(NULL); |
| 989 | } else if(e->xbutton.button == Button1) { | 987 | } else if(e->xbutton.button == Button1) { |
| 990 | sel.mode = 0; | 988 | if(sel.mode < 2) { |
| 991 | getbuttoninfo(e); | ||
| 992 | term.dirty[sel.ey] = 1; | ||
| 993 | if(sel.bx == sel.ex && sel.by == sel.ey) { | ||
| 994 | sel.bx = -1; | 989 | sel.bx = -1; |
| 995 | } else { | 990 | } else { |
| 991 | getbuttoninfo(e); | ||
| 996 | selcopy(); | 992 | selcopy(); |
| 997 | } | 993 | } |
| 994 | sel.mode = 0; | ||
| 995 | term.dirty[sel.ey] = 1; | ||
| 998 | } | 996 | } |
| 999 | } | 997 | } |
| 1000 | 998 | ||
| @@ -1010,6 +1008,7 @@ bmotion(XEvent *e) { | |||
| 1010 | if(!sel.mode) | 1008 | if(!sel.mode) |
| 1011 | return; | 1009 | return; |
| 1012 | 1010 | ||
| 1011 | sel.mode++; | ||
| 1013 | oldey = sel.ey; | 1012 | oldey = sel.ey; |
| 1014 | oldex = sel.ex; | 1013 | oldex = sel.ex; |
| 1015 | oldsby = sel.b.y; | 1014 | oldsby = sel.b.y; |
