aboutsummaryrefslogtreecommitdiff
path: root/vt.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-08 11:57:31 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-08 11:57:31 +0000
commit4e25019ba6bd1bd07925ccafc2936416ef3f7cbe (patch)
tree00c0e30177eb2e966ac021a4d42c3a9f1219f77d /vt.c
parentcell: packing the cell struct seems to help performance (diff)
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.
Diffstat (limited to 'vt.c')
-rw-r--r--vt.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/vt.c b/vt.c
index 7bab63d1..7ce2ddcb 100644
--- a/vt.c
+++ b/vt.c
@@ -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);