tDo not allow navigating right past end of file - 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 d459a5c2e81581c2019aa6ef69c99bc08d8180f2
(DIR) parent eb5c375b6985de714e2487c22e248171a8d2c926
(HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Tue, 6 Aug 2019 13:28:46 +0200
Do not allow navigating right past end of file
Diffstat:
M input.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/input.c b/input.c
t@@ -33,7 +33,8 @@ editor_move_cursor(char key)
row = (E.cursor_y >= E.num_rows) ? NULL : &E.row[E.cursor_y];
if (row && E.cursor_x < row->size) {
E.cursor_x++;
- } else if (row && E.cursor_x == row->size) {
+ } else if (row && E.cursor_x == row->size &&
+ E.cursor_y < E.num_rows - 1) {
E.cursor_y++;
E.cursor_x = 0;
}