mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
term: cursor_{up,down}: limit cursor movements based on origin mode
This commit is contained in:
parent
aee22dd4b6
commit
81215e5a72
1 changed files with 8 additions and 2 deletions
10
terminal.c
10
terminal.c
|
|
@ -1060,14 +1060,20 @@ term_cursor_right(struct terminal *term, int count)
|
|||
void
|
||||
term_cursor_up(struct terminal *term, int count)
|
||||
{
|
||||
int move_amount = min(term->cursor.row, count);
|
||||
int top = term->origin == ORIGIN_ABSOLUTE ? 0 : term->scroll_region.start;
|
||||
assert(term->cursor.row >= top);
|
||||
|
||||
int move_amount = min(term->cursor.row - top, count);
|
||||
term_cursor_to(term, term->cursor.row - move_amount, term->cursor.col);
|
||||
}
|
||||
|
||||
void
|
||||
term_cursor_down(struct terminal *term, int count)
|
||||
{
|
||||
int move_amount = min(term->rows - term->cursor.row - 1, count);
|
||||
int bottom = term->origin == ORIGIN_ABSOLUTE ? term->rows : term->scroll_region.end;
|
||||
assert(bottom >= term->cursor.row);
|
||||
|
||||
int move_amount = min(bottom - term->cursor.row - 1, count);
|
||||
term_cursor_to(term, term->cursor.row + move_amount, term->cursor.col);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue