From 77b9b35901a0cf6e98c3745485ecf1535f334897 Mon Sep 17 00:00:00 2001 From: Matuush Date: Thu, 22 May 2025 23:17:37 +0200 Subject: [PATCH] Fix jumping --- main.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 6882b0c..6eeaa8b 100644 --- a/main.cpp +++ b/main.cpp @@ -96,7 +96,7 @@ void split_line(position p) { } // Print input void print_input(string text) { - clear_line(cur.r); + clear_line(file_offset + cur.r); move(cur.r, 0); adds(text); } @@ -145,9 +145,7 @@ void jump_line_end() { cur.c = line_size; } // Move cursor within window -void move(position p) { - move(p.r, p.c); -} +void move(position p) { move(p.r, p.c); } // Cursor movement void move_cursor(char ch) { switch(ch) { @@ -191,18 +189,19 @@ void move_cursor(char ch) { break; } } -// Jump to line FIXME +// Jump to line void jump(count_type r) { if(r >= get_size()) r = get_size()-1; else if(r < 0) r = 0; if(r < file_offset) file_offset = r; - else if(r > file_offset + LINES) - file_offset = r - LINES; + else if(r >= file_offset + LINES) + file_offset = r - LINES+1; cur.r = r - file_offset; jump_line_end(); + move(cur); } // Jump to position void jump(position p) {