about summary refs log tree commit diff homepage
path: root/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'client.c')
-rw-r--r--client.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/client.c b/client.c
index 44eb904..e110686 100644
--- a/client.c
+++ b/client.c
@@ -195,6 +195,7 @@ static void clientMap(void) {
 static struct {
 	enum {
 		MODE_NORMAL,
+		MODE_DIRECTION,
 		MODE_INSERT,
 		MODE_REPLACE,
 		MODE_DRAW,
@@ -331,11 +332,26 @@ static void inputNormal(wchar_t ch) {
 
 		break; case 'i': insertMode(1, 0);
 		break; case 'a': clientMove(1, 0); insertMode(1, 0);
+		break; case 'I': input.mode = MODE_DIRECTION;
 		break; case 'r': input.mode = MODE_REPLACE;
 		break; case 'R': input.mode = MODE_DRAW; input.draw = 0;
 	}
 }
 
+static void inputDirection(wchar_t ch) {
+	switch (ch) {
+		break; case ESC: input.mode = MODE_NORMAL;
+		break; case 'h': insertMode(-1,  0);
+		break; case 'l': insertMode( 1,  0);
+		break; case 'k': insertMode( 0, -1);
+		break; case 'j': insertMode( 0,  1);
+		break; case 'y': insertMode(-1, -1);
+		break; case 'u': insertMode( 1, -1);
+		break; case 'b': insertMode(-1,  1);
+		break; case 'n': insertMode( 1,  1);
+	}
+}
+
 static void inputInsert(wchar_t ch) {
 	switch (ch) {
 		break; case ESC: {
@@ -391,10 +407,11 @@ static void readInput(void) {
 		return;
 	}
 	switch (input.mode) {
-		break; case MODE_NORMAL:  inputNormal(ch);
-		break; case MODE_INSERT:  inputInsert(ch);
-		break; case MODE_REPLACE: inputReplace(ch);
-		break; case MODE_DRAW:    inputDraw(ch);
+		break; case MODE_NORMAL:    inputNormal(ch);
+		break; case MODE_DIRECTION: inputDirection(ch);
+		break; case MODE_INSERT:    inputInsert(ch);
+		break; case MODE_REPLACE:   inputReplace(ch);
+		break; case MODE_DRAW:      inputDraw(ch);
 	}
 }