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
|
// Print input
|
||||||
void print_input(string text) {
|
void print_input(string text) {
|
||||||
clear_line(cur.r);
|
clear_line(file_offset + cur.r);
|
||||||
move(cur.r, 0);
|
move(cur.r, 0);
|
||||||
adds(text);
|
adds(text);
|
||||||
}
|
}
|
||||||
|
@ -145,9 +145,7 @@ void jump_line_end() {
|
||||||
cur.c = line_size;
|
cur.c = line_size;
|
||||||
}
|
}
|
||||||
// Move cursor within window
|
// Move cursor within window
|
||||||
void move(position p) {
|
void move(position p) { move(p.r, p.c); }
|
||||||
move(p.r, p.c);
|
|
||||||
}
|
|
||||||
// Cursor movement
|
// Cursor movement
|
||||||
void move_cursor(char ch) {
|
void move_cursor(char ch) {
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
|
@ -191,18 +189,19 @@ void move_cursor(char ch) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Jump to line FIXME
|
// Jump to line
|
||||||
void jump(count_type r) {
|
void jump(count_type r) {
|
||||||
if(r >= get_size()) r = get_size()-1;
|
if(r >= get_size()) r = get_size()-1;
|
||||||
else if(r < 0) r = 0;
|
else if(r < 0) r = 0;
|
||||||
|
|
||||||
if(r < file_offset)
|
if(r < file_offset)
|
||||||
file_offset = r;
|
file_offset = r;
|
||||||
else if(r > file_offset + LINES)
|
else if(r >= file_offset + LINES)
|
||||||
file_offset = r - LINES;
|
file_offset = r - LINES+1;
|
||||||
|
|
||||||
cur.r = r - file_offset;
|
cur.r = r - file_offset;
|
||||||
jump_line_end();
|
jump_line_end();
|
||||||
|
move(cur);
|
||||||
}
|
}
|
||||||
// Jump to position
|
// Jump to position
|
||||||
void jump(position p) {
|
void jump(position p) {
|
||||||
|
|
Loading…
Reference in a new issue