shithub: orca

Download patch

ref: 2f27233e19a1d205ca6bf94542c7fa8d922cfaa2
parent: 13da40ba1c5622a70b16d09505617dc909bb7281
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Mon Feb 17 15:29:09 EST 2020

plan9: fix mouse selection, make load/saving code easier to read, remove mainstacksize setting

--- a/plan9.c
+++ b/plan9.c
@@ -63,8 +63,6 @@
 	Rune rune;
 };
 
-int mainstacksize = 32768;
-
 static int bpm = 120, apm = 120;
 static Point rulers = {8, 8};
 static int rulerstyle = Sfancy, dotstyle = Sfancy;
@@ -966,7 +964,7 @@
 					cur = ptmouse(m.xy);
 					sel.min = cur;
 					sel.max = cur;
-				} else {
+				} else if (oldbuttons == 1) {
 					sel.max = ptmouse(m.xy);
 					sel.min = sel.max;
 					if (sel.max.x < cur.x)
@@ -981,6 +979,7 @@
 				oldbuttons = m.buttons;
 				break;
 			}
+			oldbuttons = m.buttons;
 
 			if (m.buttons == 3) { /* cut */
 				selcopy();
@@ -991,17 +990,16 @@
 				menu3i[Menu3dotstyle] = dotstyles[(dotstyle+1) % Numstyles];
 				menu3i[Menu3rulerstyle] = rulerstyles[(rulerstyle+1) % Numstyles];
 				n = menuhit(3, mctl, &menu3, nil);
-				if (n == Menu3load || n == Menu3save) {
-					strncpy(tmp, filename, sizeof(tmp));
-					if (enter(n == Menu3load ? "load from:" : "save to:", tmp, sizeof(tmp), nil, &kctl, nil) > 0) {
-						if (n == Menu3load && fieldload(tmp) == 0) {
-							w = field.width;
-							h = field.height;
-							strncpy(filename, tmp, sizeof(filename));
-						} else if (n == Menu3save && fieldsave(tmp) == 0) {
-							strncpy(filename, tmp, sizeof(filename));
-						}
+				snprint(tmp, sizeof(tmp), "%s", filename);
+				if (n == Menu3load) {
+					if (enter("load from:", tmp, sizeof(tmp), nil, &kctl, nil) > 0 && fieldload(tmp) == 0) {
+						w = field.width;
+						h = field.height;
+						snprint(filename, sizeof(filename), "%s", tmp);
 					}
+				} else if (n == Menu3save) {
+					if ((tmp[0] != 0 || enter("save to:", tmp, sizeof(tmp), nil, &kctl, nil) > 0) || fieldsave(tmp) == 0)
+						snprint(filename, sizeof(filename), "%s", tmp);
 				} else if (n == Menu3dotstyle) {
 					dotstyle = ++dotstyle % Numstyles;
 				} else if (n == Menu3rulerstyle) {
@@ -1129,7 +1127,7 @@
 				if (filename[0])
 					fieldsave(filename);
 				else if (enter("file path:", tmp, sizeof(tmp), nil, &kctl, nil) > 0 && fieldsave(tmp) == 0)
-					strncpy(filename, tmp, sizeof(filename));
+					snprint(filename, sizeof(filename), "%s", tmp);
 				break;
 			case 0x18: /* C-x */
 				selcopy();