about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
-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);
 	}
 }
 
low=1'>Make sure new cap is actually larger than new lengthJune McEnroe 2022-02-20Remove unused mbs.len field from struct EditJune McEnroe 2022-02-19Remove unneeded includes in ui.cJune McEnroe 2022-02-19Reimplement tab completeJune McEnroe 2022-02-19Handle errors from editFn, etc.June McEnroe 2022-02-19Reimplement text macrosJune McEnroe 2022-02-19Factor out input handling to input.cJune McEnroe 2022-02-19Factor out window management to window.cJune McEnroe 2022-02-19Enable -Wmissing-prototypesJune McEnroe 2022-02-19Fix edit.[ch] license notice additional permissionsJune McEnroe 2022-02-19Run line editing testsJune McEnroe 2022-02-18Implement new line editing "library"June McEnroe 2022-02-18Simplify cursor positioning in inputJune McEnroe 2022-02-18Fix M-f orderingJune McEnroe 2022-02-12Move sandman build to scripts/MakefileJune McEnroe 2022-02-12Use compat_readpassphrase.c on LinuxJune McEnroe 2022-02-12Copy RPP defines from oconfigureJune McEnroe