feat(render): add configurable attribute colors for bold, italic, and underline

Introduce optional color theme entries for bold, italic, and underline text
when the foreground color is default. This allows legacy applications using
SGR attributes instead of explicit colors to be rendered with user-defined
attribute colors. Brightening via `bold_in_bright` is suppressed when an
explicit attribute color is applied.

This adds compatibility with the rxvt-unicode settings `colorBD`,
`colorIT` and `colorUL`.

Fixes: #2261
This commit is contained in:
Florian Best 2026-01-17 03:38:53 +01:00
parent b78cc92322
commit 4864140c10
8 changed files with 60 additions and 2 deletions

View file

@ -703,6 +703,7 @@ render_cell(struct terminal *term, pixman_image_t *pix,
uint32_t _fg = 0;
uint32_t _bg = 0;
bool allow_brighten = true;
uint16_t alpha = 0xffff;
const bool is_selected = cell->attrs.selected;
@ -720,7 +721,20 @@ render_cell(struct terminal *term, pixman_image_t *pix,
break;
case COLOR_DEFAULT:
_fg = term->reverse ? term->colors.bg : term->colors.fg;
if (term->reverse) {
_fg = term->colors.bg;
} else if (cell->attrs.bold && term->colors.bold >> 24 == 0) {
_fg = term->colors.bold;
allow_brighten = false;
} else if (cell->attrs.italic && term->colors.italic >> 24 == 0) {
_fg = term->colors.italic;
allow_brighten = false;
} else if (cell->attrs.underline && term->colors.underline >> 24 == 0) {
_fg = term->colors.underline;
allow_brighten = false;
} else {
_fg = term->colors.fg;
}
break;
}
@ -839,7 +853,7 @@ render_cell(struct terminal *term, pixman_image_t *pix,
if (cell->attrs.dim)
_fg = color_dim(term, _fg);
if (term->conf->bold_in_bright.enabled && cell->attrs.bold)
if (term->conf->bold_in_bright.enabled && cell->attrs.bold && allow_brighten)
_fg = color_brighten(term, _fg);
if (cell->attrs.blink && term->blink.state == BLINK_OFF)