mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-25 06:46:36 -04:00
term: define scrollback expansion helper functions
These functions do the following: - Determine whether adding the given number of lines would overflow the terminal's scrollback - Determine whether whether the terminal should expand its scrollback capacity in order to hold the requested number of new rows, taking user configuration into account. - Expand the terminal capacity if necessary and configured to do so.
This commit is contained in:
parent
3818cbd93c
commit
800b7c423a
1 changed files with 23 additions and 0 deletions
23
terminal.c
23
terminal.c
|
|
@ -2783,6 +2783,29 @@ selection_on_bottom_region(const struct terminal *term,
|
|||
selection_on_rows(term, region.end, term->rows - 1);
|
||||
}
|
||||
|
||||
bool
|
||||
term_would_overflow_scrollback(struct terminal *term, int new_rows)
|
||||
{
|
||||
return term->grid->offset + new_rows >= term->grid->num_rows;
|
||||
}
|
||||
|
||||
bool term_should_expand_scrollback(struct terminal *term, int new_rows)
|
||||
{
|
||||
bool would_overflow = term_would_overflow_scrollback(term, new_rows);
|
||||
return term->unlimited_scrollback && would_overflow;
|
||||
}
|
||||
|
||||
bool
|
||||
term_expand_scrollback_capacity_if_needed(struct terminal *term, int new_rows)
|
||||
{
|
||||
if (term_should_expand_scrollback(term, new_rows)) {
|
||||
grid_expand_capacity(term->grid, new_rows, term->render.scrollback_lines);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
term_scroll_partial(struct terminal *term, struct scroll_region region, int rows)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue