wip: grid is now represented as a grid, not a linear array

The grid is now represented with an array of row *pointers*. Each row
contains an array of cells (the row's columns).

The main point of having row pointers is we can now move rows around
almost for free.

This is useful when scrolling with scroll margins for example, where
we previously had to copy the lines in the margins. Now it's just a
matter of swapping two pointers.
This commit is contained in:
Daniel Eklöf 2019-07-08 13:57:31 +02:00
parent 98db7f58cb
commit 4e25019ba6
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
8 changed files with 457 additions and 81 deletions

27
vt.c
View file

@ -658,6 +658,7 @@ pre_print(struct terminal *term)
static inline void
post_print(struct terminal *term)
{
term->grid->cur_row->dirty = true;
if (term->cursor.col < term->cols - 1)
term_cursor_right(term, 1);
else
@ -669,11 +670,19 @@ print_insert(struct terminal *term)
{
if (unlikely(term->insert_mode)) {
assert(false && "untested");
grid_memmove(
term->grid, term->cursor.linear + 1, term->cursor.linear,
struct row *row = term->grid->cur_row;
memmove(
&row[term->cursor.col + 1],
&row[term->cursor.col],
term->cols - term->cursor.col - 1);
#if 0
term_damage_update(
term, term->cursor.linear + 1, term->cols - term->cursor.col - 1);
#else
row->dirty = true;
#endif
}
}
@ -682,8 +691,13 @@ action_print_utf8(struct terminal *term)
{
pre_print(term);
struct cell *cell = &term->grid->cur_line[term->cursor.col];
struct row *row = term->grid->cur_row;
struct cell *cell = &row->cells[term->cursor.col];
#if 0
term_damage_update(term, term->cursor.linear, 1);
#else
row->dirty = true;
#endif
print_insert(term);
@ -701,8 +715,13 @@ action_print(struct terminal *term, uint8_t c)
{
pre_print(term);
struct cell *cell = &term->grid->cur_line[term->cursor.col];
struct row *row = term->grid->cur_row;
struct cell *cell = &row->cells[term->cursor.col];
#if 0
term_damage_update(term, term->cursor.linear, 1);
#else
row->dirty = true;
#endif
print_insert(term);