[dev] [st] [PATCH] Move calls to selsnap into selnormalize

From: Ivan Delalande <colona_AT_ycc.fr>
Date: Wed, 20 Aug 2014 21:14:08 +0200

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.
---
 st.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/st.c b/st.c
index 009388c..4bc9e70 100644
--- a/st.c
+++ b/st.c
_AT_@ -681,6 +681,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;
_AT_@ -776,15 +779,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;
_AT_@ -899,8 +893,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();
 
 		/*
-- 
2.0.4
-- 
Ivan "Colona" Delalande
Received on Wed Aug 20 2014 - 21:14:08 CEST

This archive was generated by hypermail 2.3.0 : Wed Aug 20 2014 - 21:24:07 CEST