From ca5948e8fb58197681b7007bae07c8e726a5f462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Wed, 29 Apr 2020 16:44:11 -0300 Subject: Fix scrolling when inserting at buffer end --- jet.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/jet.c b/jet.c index 131802c..3146221 100644 --- a/jet.c +++ b/jet.c @@ -60,6 +60,9 @@ int main(int argc, char *argv[]) { next_line(&window_start, window_width); } next_line(&cursor, window_width); + if (same_point(&cursor, &window_end)) { + move_point_backward(&cursor); + } break; case KEY_LEFT: if (same_point(&cursor, &window_start)) { @@ -72,6 +75,9 @@ int main(int argc, char *argv[]) { next_line(&window_start, window_width); } move_point_forward(&cursor); + if (same_point(&cursor, &window_end)) { + move_point_backward(&cursor); + } break; case KEY_BACKSPACE: if (same_point(&cursor, &window_start)) { @@ -84,6 +90,11 @@ int main(int argc, char *argv[]) { next_line(&window_start, window_width); } insert_at_point(&cursor, input); + move_point_backward(&cursor); + if (element(&cursor) == '\n') { + next_line(&window_start, window_width); + } + move_point_forward(&cursor); } } -- cgit v1.2.3