commit 02e750ce727c0cd31808ba9fde3dfe9277fb00e7
parent 01b00dbf354ccb907c467c4f62bfabf2d9e0722b
Author: ssnf <ssnf@ssnf.xyz>
Date:   Sun, 25 Jul 2021 17:15:31 +0000
added enums for move() function
Diffstat:
3 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -1,7 +1,7 @@
 Key keys = {
 	{ 'q', quit },
-	{ 'h', move, -1 },
-	{ 'j', move, +2 },
-	{ 'k', move, +1 },
-	{ 'l', move, -2 },
+	{ 'h', move, Left },
+	{ 'j', move, Down },
+	{ 'k', move, Up },
+	{ 'l', move, Right },
 }; 
diff --git a/sim.c b/sim.c
@@ -61,18 +61,18 @@ void
 move(int arg)
 {
 	switch (arg) {
-		case -1:
+		case Left:
 			if (f.dot.p0)
 				f.dot.p1 = --f.dot.p0;
 			break;
-		case +1:
+		case Right:
 			if (f.dot.p0 < f.s->n)
 				f.dot.p1 = ++f.dot.p0;
 			break;
-		case -2:
+		case Up:
 			for (;f.dot.p0 && f.s->s[f.dot.p0 - 1] != '\n'; f.dot.p1 = --f.dot.p0);
 			break;
-		case +2:
+		case Down:
 			for (;f.dot.p0 < f.s->n && f.s->s[f.dot.p0] != '\n'; f.dot.p1 = ++f.dot.p0);
 			break;
 	};
diff --git a/sim.h b/sim.h
@@ -13,6 +13,13 @@ typedef struct String  String;
 typedef struct Window  Window;
 typedef struct Key     Key;
 
+enum {
+	Up,
+	Down,
+	Left,
+	Right
+};
+
 struct Address {
 	Posn p0, p1;
 };