diff --git a/CHANGELOG.md b/CHANGELOG.md index 675e135f..a7cb54b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,12 @@ * URL underlines are now dotted by default, instead of plain underlines. This can be changed with the new `url.style` option. +* If the cursor foreground and background colors are identical, use + the current cell's foreground and background colors (inverted), + instead of the default foreground and background colors + ([#2323][2323]). + +[2323]: https://codeberg.org/dnkl/foot/issues/2323 ### Deprecated diff --git a/render.c b/render.c index f74e9251..cf5f969a 100644 --- a/render.c +++ b/render.c @@ -614,12 +614,21 @@ cursor_colors_for_cell(const struct terminal *term, const struct cell *cell, *text_color = *bg; } - if (text_color->red == cursor_color->red && - text_color->green == cursor_color->green && - text_color->blue == cursor_color->blue) + if (unlikely(text_color->red == cursor_color->red && + text_color->green == cursor_color->green && + text_color->blue == cursor_color->blue)) { - *text_color = color_hex_to_pixman(term->colors.bg, gamma_correct); - *cursor_color = color_hex_to_pixman(term->colors.fg, gamma_correct); + *text_color = *bg; + *cursor_color = *fg; + + if (text_color->red == cursor_color->red && + text_color->green == cursor_color->green && + text_color->blue == cursor_color->blue) + { + cursor_color->red = ~cursor_color->red; + cursor_color->green = ~cursor_color->green; + cursor_color->blue = ~cursor_color->blue; + } } }