tAdd 'a' binding in normal mode, do not allow cursor past last char in line - ve - a minimal text editor (work in progress)
(HTM) git clone git://src.adamsgaard.dk/ve
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit c748dcc0c2c06e50551f647e650f50d995f0823d
(DIR) parent a4e92bc5c8653de0b7835802b251e521edb9438e
(HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Tue, 6 Aug 2019 22:31:15 +0200
Add 'a' binding in normal mode, do not allow cursor past last char in line
Diffstat:
M input.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/input.c b/input.c
t@@ -81,7 +81,7 @@ editor_move_cursor(char key)
break;
case 'l':
row = (E.cursor_y >= E.num_rows) ? NULL : &E.row[E.cursor_y];
- if (row && E.cursor_x < row->size) {
+ if (row && E.cursor_x < row->size - 1) {
E.cursor_x++;
} else if (row && E.cursor_x == row->size &&
E.cursor_y < E.num_rows - 1) {
t@@ -111,6 +111,10 @@ editor_process_keypress()
case 'i':
E.mode = 1;
break;
+ case 'a':
+ editor_move_cursor('l');
+ E.mode = 1;
+ break;
case CTRL_KEY('q'):
if (E.file_changed) {
t@@ -167,7 +171,7 @@ editor_process_keypress()
break;
case '$':
if (E.cursor_y < E.num_rows)
- E.cursor_x = E.row[E.cursor_y].size;
+ E.cursor_x = E.row[E.cursor_y].size - 1;
break;
case 'g':