mirror of
https://github.com/LukeSmithxyz/st.git
synced 2024-11-22 07:15:59 +01:00
Fixing the selection handling to allow one char selection.
Thanks Alexander Sedov <alex0player@gmail.com> for suggesting the fix!
This commit is contained in:
parent
0851f2be2a
commit
1b2751f5c2
1 changed files with 9 additions and 10 deletions
19
st.c
19
st.c
|
@ -785,11 +785,8 @@ bpress(XEvent *e) {
|
||||||
sel.ey = sel.by = y2row(e->xbutton.y);
|
sel.ey = sel.by = y2row(e->xbutton.y);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Snap handling.
|
* If the user clicks below predefined timeouts specific
|
||||||
* If user clicks are fasst enough (e.g. below timeouts),
|
* snapping behaviour is exposed.
|
||||||
* we ignore if his hand slipped left or down and accidentally
|
|
||||||
* selected more; we are just snapping to whatever we're
|
|
||||||
* snapping.
|
|
||||||
*/
|
*/
|
||||||
if(TIMEDIFF(now, sel.tclick2) <= tripleclicktimeout) {
|
if(TIMEDIFF(now, sel.tclick2) <= tripleclicktimeout) {
|
||||||
sel.snap = SNAP_LINE;
|
sel.snap = SNAP_LINE;
|
||||||
|
@ -809,7 +806,8 @@ bpress(XEvent *e) {
|
||||||
* Draw selection, unless it's regular and we don't want to
|
* Draw selection, unless it's regular and we don't want to
|
||||||
* make clicks visible
|
* make clicks visible
|
||||||
*/
|
*/
|
||||||
if (sel.snap != 0) {
|
if(sel.snap != 0) {
|
||||||
|
sel.mode++;
|
||||||
tsetdirt(sel.b.y, sel.e.y);
|
tsetdirt(sel.b.y, sel.e.y);
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
@ -987,14 +985,14 @@ brelease(XEvent *e) {
|
||||||
if(e->xbutton.button == Button2) {
|
if(e->xbutton.button == Button2) {
|
||||||
selpaste(NULL);
|
selpaste(NULL);
|
||||||
} else if(e->xbutton.button == Button1) {
|
} else if(e->xbutton.button == Button1) {
|
||||||
sel.mode = 0;
|
if(sel.mode < 2) {
|
||||||
getbuttoninfo(e);
|
|
||||||
term.dirty[sel.ey] = 1;
|
|
||||||
if(sel.bx == sel.ex && sel.by == sel.ey) {
|
|
||||||
sel.bx = -1;
|
sel.bx = -1;
|
||||||
} else {
|
} else {
|
||||||
|
getbuttoninfo(e);
|
||||||
selcopy();
|
selcopy();
|
||||||
}
|
}
|
||||||
|
sel.mode = 0;
|
||||||
|
term.dirty[sel.ey] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1010,6 +1008,7 @@ bmotion(XEvent *e) {
|
||||||
if(!sel.mode)
|
if(!sel.mode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
sel.mode++;
|
||||||
oldey = sel.ey;
|
oldey = sel.ey;
|
||||||
oldex = sel.ex;
|
oldex = sel.ex;
|
||||||
oldsby = sel.b.y;
|
oldsby = sel.b.y;
|
||||||
|
|
Loading…
Reference in a new issue