diff options
author | June McEnroe <june@causal.agency> | 2018-08-23 14:53:11 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2018-08-23 14:53:11 -0400 |
commit | a2a08a114e6128c2adc10224ee7b95cc4bc1e3d1 (patch) | |
tree | c9fcc68b11ba0126246a0520b7d6f40ac0a5d32e | |
parent | Add C-l to redraw (diff) | |
download | torus-a2a08a114e6128c2adc10224ee7b95cc4bc1e3d1.tar.gz torus-a2a08a114e6128c2adc10224ee7b95cc4bc1e3d1.zip |
Implement I, directional insert
-rw-r--r-- | client.c | 25 |
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); } } |