mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
osc: color reset: read default color from currently active theme
This commit is contained in:
parent
42be74214a
commit
fcde74a181
2 changed files with 55 additions and 16 deletions
|
|
@ -84,6 +84,8 @@
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
* 10-bit surfaces sometimes used instead of 16-bit.
|
* 10-bit surfaces sometimes used instead of 16-bit.
|
||||||
|
* OSC-104/110/111/112/117/119 (reset colors) not taking the currently
|
||||||
|
active theme into account.
|
||||||
|
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
|
||||||
69
osc.c
69
osc.c
|
|
@ -1515,10 +1515,14 @@ osc_dispatch(struct terminal *term)
|
||||||
case 104: {
|
case 104: {
|
||||||
/* Reset Color Number 'c' (whole table if no parameter) */
|
/* Reset Color Number 'c' (whole table if no parameter) */
|
||||||
|
|
||||||
|
const struct color_theme *theme =
|
||||||
|
term->colors.active_theme == COLOR_THEME1
|
||||||
|
? &term->conf->colors
|
||||||
|
: &term->conf->colors2;
|
||||||
|
|
||||||
if (string[0] == '\0') {
|
if (string[0] == '\0') {
|
||||||
LOG_DBG("resetting all colors");
|
LOG_DBG("resetting all colors");
|
||||||
for (size_t i = 0; i < ALEN(term->colors.table); i++)
|
memcpy(term->colors.table, theme->table, sizeof(term->colors.table));
|
||||||
term->colors.table[i] = term->conf->colors.table[i];
|
|
||||||
term_damage_view(term);
|
term_damage_view(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1540,7 +1544,7 @@ osc_dispatch(struct terminal *term)
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DBG("resetting color #%u", idx);
|
LOG_DBG("resetting color #%u", idx);
|
||||||
term->colors.table[idx] = term->conf->colors.table[idx];
|
term->colors.table[idx] = theme->table[idx];
|
||||||
term_damage_color(term, COLOR_BASE256, idx);
|
term_damage_color(term, COLOR_BASE256, idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1553,16 +1557,28 @@ osc_dispatch(struct terminal *term)
|
||||||
|
|
||||||
case 110: /* Reset default text foreground color */
|
case 110: /* Reset default text foreground color */
|
||||||
LOG_DBG("resetting foreground color");
|
LOG_DBG("resetting foreground color");
|
||||||
term->colors.fg = term->conf->colors.fg;
|
|
||||||
|
const struct color_theme *theme =
|
||||||
|
term->colors.active_theme == COLOR_THEME1
|
||||||
|
? &term->conf->colors
|
||||||
|
: &term->conf->colors2;
|
||||||
|
|
||||||
|
term->colors.fg = theme->fg;
|
||||||
term_damage_color(term, COLOR_DEFAULT, 0);
|
term_damage_color(term, COLOR_DEFAULT, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 111: { /* Reset default text background color */
|
case 111: { /* Reset default text background color */
|
||||||
LOG_DBG("resetting background color");
|
LOG_DBG("resetting background color");
|
||||||
bool alpha_changed = term->colors.alpha != term->conf->colors.alpha;
|
|
||||||
|
|
||||||
term->colors.bg = term->conf->colors.bg;
|
const struct color_theme *theme =
|
||||||
term->colors.alpha = term->conf->colors.alpha;
|
term->colors.active_theme == COLOR_THEME1
|
||||||
|
? &term->conf->colors
|
||||||
|
: &term->conf->colors2;
|
||||||
|
|
||||||
|
bool alpha_changed = term->colors.alpha != theme->alpha;
|
||||||
|
|
||||||
|
term->colors.bg = theme->bg;
|
||||||
|
term->colors.alpha = theme->alpha;
|
||||||
|
|
||||||
if (alpha_changed) {
|
if (alpha_changed) {
|
||||||
wayl_win_alpha_changed(term->window);
|
wayl_win_alpha_changed(term->window);
|
||||||
|
|
@ -1574,10 +1590,16 @@ osc_dispatch(struct terminal *term)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 112:
|
case 112: {
|
||||||
LOG_DBG("resetting cursor color");
|
LOG_DBG("resetting cursor color");
|
||||||
term->colors.cursor_fg = term->conf->colors.cursor.text;
|
|
||||||
term->colors.cursor_bg = term->conf->colors.cursor.cursor;
|
const struct color_theme *theme =
|
||||||
|
term->colors.active_theme == COLOR_THEME1
|
||||||
|
? &term->conf->colors
|
||||||
|
: &term->conf->colors2;
|
||||||
|
|
||||||
|
term->colors.cursor_fg = theme->cursor.text;
|
||||||
|
term->colors.cursor_bg = theme->cursor.cursor;
|
||||||
|
|
||||||
if (term->conf->colors.use_custom.cursor) {
|
if (term->conf->colors.use_custom.cursor) {
|
||||||
term->colors.cursor_fg |= 1u << 31;
|
term->colors.cursor_fg |= 1u << 31;
|
||||||
|
|
@ -1586,16 +1608,31 @@ osc_dispatch(struct terminal *term)
|
||||||
|
|
||||||
term_damage_cursor(term);
|
term_damage_cursor(term);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 117:
|
case 117: {
|
||||||
LOG_DBG("resetting selection background color");
|
LOG_DBG("resetting selection background color");
|
||||||
term->colors.selection_bg = term->conf->colors.selection_bg;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 119:
|
const struct color_theme *theme =
|
||||||
LOG_DBG("resetting selection foreground color");
|
term->colors.active_theme == COLOR_THEME1
|
||||||
term->colors.selection_fg = term->conf->colors.selection_fg;
|
? &term->conf->colors
|
||||||
|
: &term->conf->colors2;
|
||||||
|
|
||||||
|
term->colors.selection_bg = theme->selection_bg;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 119: {
|
||||||
|
LOG_DBG("resetting selection foreground color");
|
||||||
|
|
||||||
|
const struct color_theme *theme =
|
||||||
|
term->colors.active_theme == COLOR_THEME1
|
||||||
|
? &term->conf->colors
|
||||||
|
: &term->conf->colors2;
|
||||||
|
|
||||||
|
term->colors.selection_fg = theme->selection_fg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 133:
|
case 133:
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue