osc: don’t damage the entire view on a single color palette update

Instead, loop the viewport and dirty only those cells that are
affected by the palette change.
This commit is contained in:
Daniel Eklöf 2022-02-10 18:27:20 +01:00
parent 3c232bec28
commit d34c8007f1
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

42
osc.c
View file

@ -614,7 +614,47 @@ osc_dispatch(struct terminal *term)
idx, term->colors.table[idx], color);
term->colors.table[idx] = color;
term_damage_view(term);
/* Dirty visible, affected cells */
for (int r = 0; r < term->rows; r++) {
struct row *row = grid_row_in_view(term->grid, r);
struct cell *cell = &row->cells[0];
for (int c = 0; c < term->cols; c++, cell++) {
bool dirty = false;
switch (cell->attrs.fg_src) {
case COLOR_BASE16:
case COLOR_BASE256:
if (cell->attrs.fg == idx)
dirty = true;
break;
case COLOR_DEFAULT:
case COLOR_RGB:
/* Not affected */
break;
}
switch (cell->attrs.bg_src) {
case COLOR_BASE16:
case COLOR_BASE256:
if (cell->attrs.bg == idx)
dirty = true;
break;
case COLOR_DEFAULT:
case COLOR_RGB:
/* Not affected */
break;
}
if (dirty) {
cell->attrs.clean = 0;
row->dirty = true;
}
}
}
}
}