shithub: orca

Download patch

ref: 95aa7eb86bc157c28e419968bddc397a3d5117c2
parent: 3ee1abfee2c681bef131cc43c5171e199eebf47e
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Feb 17 05:51:45 EST 2020

plan9: simplify selext

--- a/plan9.c
+++ b/plan9.c
@@ -785,29 +785,15 @@
 static void
 selext(int xdt, int ydt)
 {
-	if (xdt > 0) {
-		if (sel.min.x < cur.x)
-			sel.min.x += xdt;
-		else
-			sel.max.x += xdt;
-	} else {
-		if (sel.max.x > cur.x)
-			sel.max.x += xdt;
-		else
-			sel.min.x += xdt;
-	}
+	if (sel.max.x > cur.x || (sel.min.x == cur.x && xdt > 0))
+		sel.max.x += xdt;
+	else
+		sel.min.x += xdt;
 
-	if (ydt > 0) {
-		if (sel.min.y < cur.y)
-			sel.min.y += ydt;
-		else
-			sel.max.y += ydt;
-	} else {
-		if (sel.max.y > cur.y)
-			sel.max.y += ydt;
-		else
-			sel.min.y += ydt;
-	}
+	if (sel.max.y > cur.y || (sel.min.y == cur.y && ydt > 0))
+		sel.max.y += ydt;
+	else
+		sel.min.y += ydt;
 
 	sel.min.x = MAX(0, MIN((int)field.width-1, sel.min.x));
 	sel.max.x = MAX(0, MIN((int)field.width-1, sel.max.x));