diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-07-08 11:57:31 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-07-08 11:57:31 +0000 |
| commit | 4e25019ba6bd1bd07925ccafc2936416ef3f7cbe (patch) | |
| tree | 00c0e30177eb2e966ac021a4d42c3a9f1219f77d /csi.c | |
| parent | cell: 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 'csi.c')
| -rw-r--r-- | csi.c | 65 |
1 files changed, 41 insertions, 24 deletions
@@ -338,25 +338,26 @@ csi_dispatch(struct terminal *term, uint8_t final) /* Erase screen */ int param = param_get(term, 0, 0); - int start = -1; - int end = -1; switch (param) { case 0: /* From cursor to end of screen */ - start = term->cursor.linear; - end = term->cols * term->rows; + term_erase( + term, + &term->cursor, + &(struct coord){term->cols - 1, term->rows - 1}); break; case 1: /* From start of screen to cursor */ - start = 0; - end = term->cursor.linear; + term_erase(term, &(struct coord){0, 0}, &term->cursor); break; case 2: /* Erase entire screen */ - start = 0; - end = term->cols * term->rows; + term_erase( + term, + &(struct coord){0, 0}, + &(struct coord){term->cols - 1, term->rows - 1}); break; default: @@ -365,8 +366,6 @@ csi_dispatch(struct terminal *term, uint8_t final) abort(); break; } - - term_erase(term, start, end); break; } @@ -374,25 +373,27 @@ csi_dispatch(struct terminal *term, uint8_t final) /* Erase line */ int param = param_get(term, 0, 0); - int start = -1; - int end = -1; switch (param) { case 0: /* From cursor to end of line */ - start = term->cursor.linear; - end = term_cursor_linear(term, term->cursor.row, term->cols); + term_erase( + term, + &term->cursor, + &(struct coord){term->cols - 1, term->cursor.row}); break; case 1: /* From start of line to cursor */ - start = term_cursor_linear(term, term->cursor.row, 0); - end = term->cursor.linear; + term_erase( + term, &(struct coord){0, term->cursor.row}, &term->cursor); break; case 2: /* Entire line */ - start = term_cursor_linear(term, term->cursor.row, 0); - end = term_cursor_linear(term, term->cursor.row, term->cols); + term_erase( + term, + &(struct coord){0, term->cursor.row}, + &(struct coord){term->cols - 1, term->cursor.row}); break; default: @@ -402,7 +403,6 @@ csi_dispatch(struct terminal *term, uint8_t final) break; } - term_erase(term, start, end); break; } @@ -453,15 +453,25 @@ csi_dispatch(struct terminal *term, uint8_t final) int remaining = term->cols - (term->cursor.col + count); /* 'Delete' characters by moving the remaining ones */ - memmove(&term->grid->cur_line[term->cursor.col], - &term->grid->cur_line[term->cursor.col + count], - remaining * sizeof(term->grid->cur_line[0])); + memmove(&term->grid->cur_row->cells[term->cursor.col], + &term->grid->cur_row->cells[term->cursor.col + count], + remaining * sizeof(term->grid->cur_row->cells[0])); +#if 0 term_damage_update(term, term->cursor.linear, remaining); +#else + term->grid->cur_row->dirty = true; +#endif /* Erase the remainder of the line */ term_erase( + term, + &(struct coord){term->cursor.col + remaining, term->cursor.row}, + &(struct coord){term->cols - 1, term->cursor.row}); +#if 0 + term_erase( term, term->cursor.linear + remaining, term->cursor.linear + remaining + count); +#endif break; } @@ -478,9 +488,16 @@ csi_dispatch(struct terminal *term, uint8_t final) int count = min( param_get(term, 0, 1), term->cols - term->cursor.col); + term_erase( + term, + &term->cursor, + &(struct coord){term->cursor.col + count, term->cursor.row}); + +#if 0 memset(&term->grid->cur_line[term->cursor.col], 0, count * sizeof(term->grid->cur_line[0])); term_damage_erase(term, term->cursor.linear, count); +#endif break; } @@ -630,8 +647,8 @@ csi_dispatch(struct terminal *term, uint8_t final) tll_free(term->alt.damage); tll_free(term->alt.scroll_damage); - grid_memclear(term->grid, 0, term->rows * term->cols); - term_damage_erase(term, 0, term->rows * term->cols); + //grid_memclear(term->grid, 0, term->rows * term->cols); + //term_damage_erase(term, 0, term->rows * term->cols); } break; |
