summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lohmann2013-04-25 06:28:11 +0200
committerChristoph Lohmann2013-04-25 06:28:11 +0200
commit1b2751f5c24ca06afbb68e41e73fc9fce6c6b521 (patch)
tree8734f7a2900ed8d5443df94671665f91d68cba33
parent0851f2be2ab48ee3a67ef2287c09bd67622dcd8e (diff)
downloadst-1b2751f5c24ca06afbb68e41e73fc9fce6c6b521.tar.gz
st-1b2751f5c24ca06afbb68e41e73fc9fce6c6b521.tar.xz
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.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/st.c b/st.c
index c0a4780..8d27c94 100644
--- a/st.c
+++ b/st.c
@@ -785,11 +785,8 @@ bpress(XEvent *e) {
sel.ey = sel.by = y2row(e->xbutton.y);
/*
- * Snap handling.
- * If user clicks are fasst enough (e.g. below timeouts),
- * we ignore if his hand slipped left or down and accidentally
- * selected more; we are just snapping to whatever we're
- * snapping.
+ * If the user clicks below predefined timeouts specific
+ * snapping behaviour is exposed.
*/
if(TIMEDIFF(now, sel.tclick2) <= tripleclicktimeout) {
sel.snap = SNAP_LINE;
@@ -809,7 +806,8 @@ bpress(XEvent *e) {
* Draw selection, unless it's regular and we don't want to
* make clicks visible
*/
- if (sel.snap != 0) {
+ if(sel.snap != 0) {
+ sel.mode++;
tsetdirt(sel.b.y, sel.e.y);
draw();
}
@@ -987,14 +985,14 @@ brelease(XEvent *e) {
if(e->xbutton.button == Button2) {
selpaste(NULL);
} else if(e->xbutton.button == Button1) {
- sel.mode = 0;
- getbuttoninfo(e);
- term.dirty[sel.ey] = 1;
- if(sel.bx == sel.ex && sel.by == sel.ey) {
+ if(sel.mode < 2) {
sel.bx = -1;
} else {
+ getbuttoninfo(e);
selcopy();
}
+ sel.mode = 0;
+ term.dirty[sel.ey] = 1;
}
}
@@ -1010,6 +1008,7 @@ bmotion(XEvent *e) {
if(!sel.mode)
return;
+ sel.mode++;
oldey = sel.ey;
oldex = sel.ex;
oldsby = sel.b.y;