summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-29 16:44:11 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-29 16:44:11 -0300
commitca5948e8fb58197681b7007bae07c8e726a5f462 (patch)
treed2e982bb741e70fa22bb9d71344db376db1051ee
parentbadecae294cdd8f9d67c1239a291d481dfb4e1a3 (diff)
downloadjet-ca5948e8fb58197681b7007bae07c8e726a5f462.tar.gz
jet-ca5948e8fb58197681b7007bae07c8e726a5f462.zip
Fix scrolling when inserting at buffer end
-rw-r--r--jet.c11
1 files changed, 11 insertions, 0 deletions
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);
}
}