From 418bc15176439c9315d4b789b24097e588f0e024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Wed, 29 Apr 2020 13:34:01 -0300 Subject: Make sure cursor is always on screen --- jet.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jet.c b/jet.c index e5a75b7..200b93d 100644 --- a/jet.c +++ b/jet.c @@ -62,9 +62,15 @@ int main(int argc, char *argv[]) { next_line(&cursor, window_width); break; case KEY_LEFT: + if (same_point(&cursor, &window_start)) { + prev_line(&window_start, window_width); + } move_point_backward(&cursor); break; case KEY_RIGHT: + if (same_point(&cursor, &window_end)) { + next_line(&window_start, window_width); + } move_point_forward(&cursor); break; case KEY_BACKSPACE: -- cgit v1.2.3