mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-05-15 21:45:03 -04:00
render: cursor: improve handling of fg == bg
We already detect if the final cursor colors (foreground/background) are identical. If they were, we replaced them with the default fg/bg. Unfortunately, this can still result in an invisible cursor. For example, if the current cell's default bg matches the current cell's fg. Instead, update the colors in two steps: 1. First, use the provided (cell's) fg/bg 2. If they too match, invert the cursor color This should ensure the cursor is always visible Closes #2323
This commit is contained in:
parent
a2476536f9
commit
cc6b29fe3a
2 changed files with 20 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
19
render.c
19
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue