mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-14 05:33:59 -04:00
term: "cache" pointer to current line
This adds a pointer to the first cell on the current line. This pointer must be updated every time the row changes. The advantage is mainly that PRINT doesn't have to call grid_get_range(), which is fairly expensive.
This commit is contained in:
parent
ed68eafdf0
commit
9682e15deb
3 changed files with 14 additions and 5 deletions
12
terminal.c
12
terminal.c
|
|
@ -169,6 +169,12 @@ term_cursor_to(struct terminal *term, int row, int col)
|
||||||
term->cursor.linear = new_linear;
|
term->cursor.linear = new_linear;
|
||||||
term->cursor.col = col;
|
term->cursor.col = col;
|
||||||
term->cursor.row = row;
|
term->cursor.row = row;
|
||||||
|
|
||||||
|
size_t len = term->cols;
|
||||||
|
term->grid->cur_line = grid_get_range(
|
||||||
|
term->grid, term->cursor.linear - col, &len);
|
||||||
|
|
||||||
|
assert(len == (size_t)term->cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -253,6 +259,12 @@ term_scroll_partial(struct terminal *term, struct scroll_region region, int rows
|
||||||
max(0, region.end - rows) * term->cols, 0, rows * term->cols);
|
max(0, region.end - rows) * term->cols, 0, rows * term->cols);
|
||||||
|
|
||||||
term_damage_scroll(term, DAMAGE_SCROLL, region, rows);
|
term_damage_scroll(term, DAMAGE_SCROLL, region, rows);
|
||||||
|
|
||||||
|
size_t len = term->cols;
|
||||||
|
term->grid->cur_line = grid_get_range(
|
||||||
|
term->grid, term->cursor.linear - term->cursor.col, &len);
|
||||||
|
|
||||||
|
assert(len == (size_t)term->cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ struct grid {
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
struct cell *cells;
|
struct cell *cells;
|
||||||
|
struct cell *cur_line;
|
||||||
|
|
||||||
tll(struct damage) damage;
|
tll(struct damage) damage;
|
||||||
tll(struct damage) scroll_damage;
|
tll(struct damage) scroll_damage;
|
||||||
|
|
|
||||||
6
vt.c
6
vt.c
|
|
@ -678,11 +678,7 @@ action(struct terminal *term, enum action action, uint8_t c)
|
||||||
term_cursor_to(term, term->cursor.row + 1, 0);
|
term_cursor_to(term, term->cursor.row + 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t cell_count = 1;
|
struct cell *cell = &term->grid->cur_line[term->cursor.col];
|
||||||
struct cell *cell = grid_get_range(
|
|
||||||
term->grid, term->cursor.linear, &cell_count);
|
|
||||||
assert(cell_count == 1);
|
|
||||||
|
|
||||||
term_damage_update(term, term->cursor.linear, 1);
|
term_damage_update(term, term->cursor.linear, 1);
|
||||||
|
|
||||||
if (term->vt.utf8.idx > 0) {
|
if (term->vt.utf8.idx > 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue