aboutsummaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authorIvan Delalande <colona@ycc.fr>2014-08-20 21:14:08 +0200
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2014-08-21 17:50:31 +0200
commitc490a60b804f467490cd4d8275a181dc37edef9f (patch)
treeafe57826d9952cd9335cde781cf1fcb4a6ce3235 /st.c
parent83dea7fd7bb5f6e8a11a7ac8a734d8016d1ed0cb (diff)
downloadst-c490a60b804f467490cd4d8275a181dc37edef9f.tar.gz
st-c490a60b804f467490cd4d8275a181dc37edef9f.tar.bz2
Move calls to selsnap into selnormalize
This simplifies getbuttoninfo() and bpress(), and fixes a bug which made word snapping behave incorrectly when a delimiter was at the beginning or end of line. Signed-off-by: Roberto E. Vargas Caballero <k0ga@shike2.com>
Diffstat (limited to 'st.c')
-rw-r--r--st.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/st.c b/st.c
index 6165119..01ab962 100644
--- a/st.c
+++ b/st.c
@@ -682,6 +682,9 @@ selnormalize(void) {
sel.nb.y = MIN(sel.ob.y, sel.oe.y);
sel.ne.y = MAX(sel.ob.y, sel.oe.y);
+ selsnap(sel.snap, &sel.nb.x, &sel.nb.y, -1);
+ selsnap(sel.snap, &sel.ne.x, &sel.ne.y, +1);
+
/* expand selection over line breaks */
if (sel.type == SEL_RECTANGULAR)
return;
@@ -777,15 +780,6 @@ getbuttoninfo(XEvent *e) {
sel.oe.x = x2col(e->xbutton.x);
sel.oe.y = y2row(e->xbutton.y);
-
- if(sel.ob.y < sel.oe.y
- || (sel.ob.y == sel.oe.y && sel.ob.x < sel.oe.x)) {
- selsnap(sel.snap, &sel.ob.x, &sel.ob.y, -1);
- selsnap(sel.snap, &sel.oe.x, &sel.oe.y, +1);
- } else {
- selsnap(sel.snap, &sel.oe.x, &sel.oe.y, -1);
- selsnap(sel.snap, &sel.ob.x, &sel.ob.y, +1);
- }
selnormalize();
sel.type = SEL_REGULAR;
@@ -900,8 +894,6 @@ bpress(XEvent *e) {
} else {
sel.snap = 0;
}
- selsnap(sel.snap, &sel.ob.x, &sel.ob.y, -1);
- selsnap(sel.snap, &sel.oe.x, &sel.oe.y, +1);
selnormalize();
/*