Fix jumping

This commit is contained in:
Matúš Púll 2025-05-22 23:17:37 +02:00
parent d88d27377f
commit 77b9b35901

View file

@ -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) {