aboutsummaryrefslogtreecommitdiff
path: root/osc.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-07-03 08:53:33 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-07-03 08:53:33 +0000
commit22c8637610e15d2c84509a484fee41bccd0ad0fe (patch)
treed305a2bd3751b546b635c312551650604299a853 /osc.c
parentMerge branch 'color-stack' (diff)
osc: extend damage-cells-by-color to default fg/bg as well
When changing part of the color palette, through either OSC-4, or OSC-10 and OSC-11 (and the corresponding reset OSCs: 104, 110 and 111), only dirty affected cells. We've always done this, but only for OSC-4. This patch breaks out that logic, and extends it to handle default fg/bg too. It also fixes a bug where cells with colored underlines were not dirtied if the underline was the only part of the cell that was affected by a OSC-4 change.
Diffstat (limited to 'osc.c')
-rw-r--r--osc.c56
1 files changed, 7 insertions, 49 deletions
diff --git a/osc.c b/osc.c
index d9e952c0..a3dc1715 100644
--- a/osc.c
+++ b/osc.c
@@ -651,47 +651,7 @@ osc_dispatch(struct terminal *term)
idx, term->colors.table[idx], color);
term->colors.table[idx] = color;
-
- /* 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;
- }
- }
- }
+ term_damage_color(term, COLOR_BASE256, idx);
}
}
@@ -772,7 +732,7 @@ osc_dispatch(struct terminal *term)
switch (param) {
case 10:
term->colors.fg = color;
- term_damage_view(term);
+ term_damage_color(term, COLOR_DEFAULT, 0);
break;
case 11:
@@ -786,7 +746,7 @@ osc_dispatch(struct terminal *term)
term_font_subpixel_changed(term);
}
}
- term_damage_view(term);
+ term_damage_color(term, COLOR_DEFAULT, 0);
term_damage_margins(term);
break;
@@ -798,13 +758,11 @@ osc_dispatch(struct terminal *term)
case 17:
term->colors.selection_bg = color;
term->colors.use_custom_selection = true;
- term_damage_view(term);
break;
case 19:
term->colors.selection_fg = color;
term->colors.use_custom_selection = true;
- term_damage_view(term);
break;
}
@@ -829,6 +787,7 @@ osc_dispatch(struct terminal *term)
LOG_DBG("resetting all colors");
for (size_t i = 0; i < ALEN(term->colors.table); i++)
term->colors.table[i] = term->conf->colors.table[i];
+ term_damage_view(term);
}
else {
@@ -850,11 +809,10 @@ osc_dispatch(struct terminal *term)
LOG_DBG("resetting color #%u", idx);
term->colors.table[idx] = term->conf->colors.table[idx];
+ term_damage_color(term, COLOR_BASE256, idx);
}
}
-
- term_damage_view(term);
break;
}
@@ -864,14 +822,14 @@ osc_dispatch(struct terminal *term)
case 110: /* Reset default text foreground color */
LOG_DBG("resetting foreground color");
term->colors.fg = term->conf->colors.fg;
- term_damage_view(term);
+ term_damage_color(term, COLOR_DEFAULT, 0);
break;
case 111: /* Reset default text background color */
LOG_DBG("resetting background color");
term->colors.bg = term->conf->colors.bg;
term->colors.alpha = term->conf->colors.alpha;
- term_damage_view(term);
+ term_damage_color(term, COLOR_DEFAULT, 0);
term_damage_margins(term);
break;