mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-16 05:34:00 -04:00
increment/decrement follow cursor
This commit is contained in:
parent
36784b59fa
commit
602e6c1ebc
1 changed files with 10 additions and 0 deletions
10
vimode.c
10
vimode.c
|
|
@ -877,6 +877,11 @@ bool increment_cursor(struct terminal *const term) {
|
||||||
if (term->vimode.cursor.row != term->rows - 1) {
|
if (term->vimode.cursor.row != term->rows - 1) {
|
||||||
term->vimode.cursor.row += 1;
|
term->vimode.cursor.row += 1;
|
||||||
term->vimode.cursor.col = 0;
|
term->vimode.cursor.col = 0;
|
||||||
|
// If the cursor moved outside the view, follow it.
|
||||||
|
struct coord cursor = cursor_to_view_relative(term, term->vimode.cursor);
|
||||||
|
if (cursor.row >= term->rows) {
|
||||||
|
cmd_scrollback_down(term, 1);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -911,6 +916,11 @@ bool decrement_cursor(struct terminal *const term) {
|
||||||
if (sb_row > 0) {
|
if (sb_row > 0) {
|
||||||
term->vimode.cursor.row -= 1;
|
term->vimode.cursor.row -= 1;
|
||||||
term->vimode.cursor.col = row_length(term, term->vimode.cursor.row) - 1;
|
term->vimode.cursor.col = row_length(term, term->vimode.cursor.row) - 1;
|
||||||
|
// If the cursor moved outside the view, follow it.
|
||||||
|
struct coord cursor = cursor_to_view_relative(term, term->vimode.cursor);
|
||||||
|
if (cursor.row < 0) {
|
||||||
|
cmd_scrollback_up(term, 1);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue