shithub: orca

Download patch

ref: ab94883dcfe54c3f6e93e96e7a70cc254b8415eb
parent: 3c2814b50e808849a6835a9b50265525e2d9a7d4
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Apr 30 13:30:01 EDT 2020

plan9: fix selection extending when both Ctrl and Shift are pressed, use rectclip to simplify as well

--- a/plan9.c
+++ b/plan9.c
@@ -485,19 +485,16 @@
 selext(int xdt, int ydt)
 {
 	if (sel.max.x > cur.x || (sel.min.x == cur.x && xdt > 0))
-		sel.max.x += xdt;
+		sel.max.x = MAX(sel.max.x+xdt, sel.min.x);
 	else
-		sel.min.x += xdt;
+		sel.min.x = MIN(sel.min.x+xdt, sel.max.x);
 
 	if (sel.max.y > cur.y || (sel.min.y == cur.y && ydt > 0))
-		sel.max.y += ydt;
+		sel.max.y = MAX(sel.max.y+ydt, sel.min.y);
 	else
-		sel.min.y += ydt;
+		sel.min.y = MIN(sel.min.y+ydt, sel.max.y);
 
-	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));
-	sel.min.y = MAX(0, MIN((int)field.height-1, sel.min.y));
-	sel.max.y = MAX(0, MIN((int)field.height-1, sel.max.y));
+	rectclip(&sel, Rect(0, 0, (int)field.width-1, (int)field.height-1));
 }
 
 /*