Fix jumping
This commit is contained in:
parent
d88d27377f
commit
77b9b35901
1 changed files with 6 additions and 7 deletions
13
main.cpp
13
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) {
|
||||
|
|
Loading…
Reference in a new issue