summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-29 13:34:01 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-29 13:34:01 -0300
commit418bc15176439c9315d4b789b24097e588f0e024 (patch)
tree8eeabbcd9f3d52b0bc37cbff16989c829cdee2aa
parent839ff03b98de80ba367872f5f6d8cd28e706152b (diff)
downloadjet-418bc15176439c9315d4b789b24097e588f0e024.tar.gz
jet-418bc15176439c9315d4b789b24097e588f0e024.zip
Make sure cursor is always on screen
-rw-r--r--jet.c6
1 files changed, 6 insertions, 0 deletions
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: