aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-07-01 08:53:21 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-07-01 08:53:21 +0000
commit7341ba5ee35e95c36fa90fcab912774615f7f2e1 (patch)
tree34dc8eaae608a35d9e1f387e02d145d35278fa58 /render.c
parentMerge branch 'curly-underlines' (diff)
render: cursor color: remove assertion that both cursor fg/bg be set
Before this patch, we asserted both the cursor foreground, and background colors had been set. This is true in most cases; the config system enforces it. It is however possible to set only the cursor background color, while leaving the foreground (text) color unset: * Use a foot config that does *not* configure the cursor colors. This means foot will invert the default fg/bg colors when rendering the cursor. * Override the cursor color using an OSC-12 sequence. OSC-12 only sets the background color of the cursor, and there is no other OSC sequence to set the cursor's text color. To handle this, remove the assertion, and simply split the logic for the cursor backgound and foreground colors: * Use the configured background color if set (either through config or OSC-12), otherwise use the default foreground color. * Use the configured foreground color if set (through config), otherwise use the default background color.
Diffstat (limited to 'render.c')
-rw-r--r--render.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/render.c b/render.c
index 35b7c6ae..1853eb48 100644
--- a/render.c
+++ b/render.c
@@ -556,13 +556,14 @@ cursor_colors_for_cell(const struct terminal *term, const struct cell *cell,
const pixman_color_t *fg, const pixman_color_t *bg,
pixman_color_t *cursor_color, pixman_color_t *text_color)
{
- if (term->cursor_color.cursor >> 31) {
- xassert(term->cursor_color.text >> 31);
-
+ if (term->cursor_color.cursor >> 31)
*cursor_color = color_hex_to_pixman(term->cursor_color.cursor);
- *text_color = color_hex_to_pixman(term->cursor_color.text);
- } else {
+ else
*cursor_color = *fg;
+
+ if (term->cursor_color.text >> 31)
+ *text_color = color_hex_to_pixman(term->cursor_color.text);
+ else {
*text_color = *bg;
if (unlikely(text_color->alpha != 0xffff)) {