grid: define capacity expansion function

Allocates a new array of rows of the desired capacity
and copies all the grid's rows over to it.
Assumes the new capacity is greater than the old capacity.
In other words, can only be used to expand capacity, not shrink it.
This commit is contained in:
Matheus Afonso Martins Moreira 2024-04-07 05:46:31 -03:00
parent 297b5c4734
commit 3818cbd93c
2 changed files with 63 additions and 0 deletions

4
grid.h
View file

@ -11,6 +11,10 @@ void grid_swap_row(struct grid *grid, int row_a, int row_b);
struct row *grid_row_alloc(int cols, bool initialize);
void grid_row_free(struct row *row);
void grid_expand_capacity(
struct grid *grid, int minimum,
int scrollback_lines);
void grid_resize_without_reflow(
struct grid *grid, int new_rows, int new_cols,
int old_screen_rows, int new_screen_rows);