diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-06-14 07:34:46 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-06-14 07:34:46 +0000 |
| commit | c94cbdeb647cf66d20a9338a7171c2fd4299b208 (patch) | |
| tree | 3622cd9e7acfa648a80729d8c38ea01077409078 | |
| parent | changelog: language (diff) | |
osc: set color: update both grids, but exclude scrollback
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | osc.c | 40 |
2 files changed, 24 insertions, 20 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b2e5bad..7753da42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,8 +30,8 @@ double forked. * Unicode combining character overflow errors are only logged when debug logging has been enabled. -* OSC 4 (_Set Color_) now updates already rendered cells in the - **current** grid (_normal_ or _alternate_). +* OSC 4 (_Set Color_) now updates already rendered cells, excluding + scrollback. ### Deprecated @@ -9,6 +9,7 @@ #define LOG_ENABLE_DBG 0 #include "log.h" #include "base64.h" +#include "grid.h" #include "render.h" #include "selection.h" #include "terminal.h" @@ -491,27 +492,30 @@ osc_dispatch(struct terminal *term) * hope that it is unusual with palettes where all the * colors aren't unique. * - * TODO: we should update *both* grids... but that's - * really really slow. Normal usage of this OSC is by - * full-screen applications using the alt screen. + * TODO(?): for performance reasons, we only update + * the current screen rows (of both + * grids). I.e. scrollback is *not* updates. */ - for (size_t r = 0; r < term->grid->num_rows; r++) { - struct row *row = term->grid->rows[r]; - if (row == NULL) - continue; + for (size_t i = 0; i < 2; i++) { + struct grid *grid = i == 0 ? &term->normal : &term->alt; - for (size_t c = 0; c < term->grid->num_cols; c++) { - struct cell *cell = &row->cells[c]; - if (cell->attrs.have_fg && cell->attrs.fg == term->colors.table[idx]) { - cell->attrs.fg = color; - cell->attrs.clean = 0; - row->dirty = true; - } + for (size_t r = 0; r < term->rows; r++) { + struct row *row = grid_row(grid, r); + assert(row != NULL); + + for (size_t c = 0; c < term->grid->num_cols; c++) { + struct cell *cell = &row->cells[c]; + if (cell->attrs.have_fg && cell->attrs.fg == term->colors.table[idx]) { + cell->attrs.fg = color; + cell->attrs.clean = 0; + row->dirty = true; + } - if (cell->attrs.have_bg && cell->attrs.bg == term->colors.table[idx]) { - cell->attrs.bg = color; - cell->attrs.clean = 0; - row->dirty = true; + if (cell->attrs.have_bg && cell->attrs.bg == term->colors.table[idx]) { + cell->attrs.bg = color; + cell->attrs.clean = 0; + row->dirty = true; + } } } } |
