tAllow left/right navigation across start of lines and end of lines - ve - a mi… | |
git clone git://src.adamsgaard.dk/ve | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit eb5c375b6985de714e2487c22e248171a8d2c926 | |
parent ff5731cf9db9e1933a13654bce29476117121ab5 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Tue, 6 Aug 2019 13:27:05 +0200 | |
Allow left/right navigation across start of lines and end of lines | |
Diffstat: | |
M input.c | 14 +++++++++++--- | |
1 file changed, 11 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/input.c b/input.c | |
t@@ -14,21 +14,29 @@ editor_move_cursor(char key) | |
switch(key) { | |
case 'h': | |
- if (E.cursor_x > 0) | |
+ if (E.cursor_x != 0) { | |
E.cursor_x--; | |
+ } else if (E.cursor_y > 0) { | |
+ E.cursor_y--; | |
+ E.cursor_x = E.row[E.cursor_y].size; | |
+ } | |
break; | |
case 'j': | |
if (E.cursor_y < E.num_rows - 1) | |
E.cursor_y++; | |
break; | |
case 'k': | |
- if (E.cursor_y > 0) | |
+ if (E.cursor_y != 0) | |
E.cursor_y--; | |
break; | |
case 'l': | |
row = (E.cursor_y >= E.num_rows) ? NULL : &E.row[E.cur… | |
- if (row && E.cursor_x < row->size) | |
+ if (row && E.cursor_x < row->size) { | |
E.cursor_x++; | |
+ } else if (row && E.cursor_x == row->size) { | |
+ E.cursor_y++; | |
+ E.cursor_x = 0; | |
+ } | |
break; | |
} | |