From b3745b31c72042adf523b54be7c2a297a82cca7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 14 Jul 2023 09:51:06 +0200 Subject: [PATCH] =?UTF-8?q?render:=20don=E2=80=99t=20invert=20cursor=20col?= =?UTF-8?q?ors=20when=20custom=20colors=20are=20being=20used?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the user has configured custom cursor colors (cursor.color is set in foot.ini), don’t invert those colors when the cell is either selected, or has the ‘reverse’ attribute set. This aligns foot’s behavior with Alacritty, Kitty and Wezterm. Contour also behaves similarly, except mouse selections override the cursor colors (turning the cursor invisible). Closes #1347 --- CHANGELOG.md | 5 +++++ render.c | 14 +++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 968dd1a3..cbae76c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,11 +94,16 @@ ([#1383][1383]). * `dpi-aware` now defaults to `no`, and the `auto` value has been removed. +* When using custom cursor colors (`cursor.color` is set in + `foot.ini`), the cursor is no longer inverted when the cell is + selected, or when the cell has the `reverse` (SGR 7) attribute set + ([#1347][1347]). [1371]: https://codeberg.org/dnkl/foot/pulls/1371 [1183]: https://codeberg.org/dnkl/foot/issues/1183 [1360]: https://codeberg.org/dnkl/foot/issues/1360 [1383]: https://codeberg.org/dnkl/foot/issues/1383 +[1347]: https://codeberg.org/dnkl/foot/issues/1347 ### Deprecated diff --git a/render.c b/render.c index 5a757a88..677856d8 100644 --- a/render.c +++ b/render.c @@ -405,19 +405,11 @@ 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) { - bool is_selected = cell->attrs.selected; - 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 >> 31 - ? term->cursor_color.text : term->colors.bg); + xassert(term->cursor_color.text >> 31); - if (cell->attrs.reverse ^ is_selected) { - pixman_color_t swap = *cursor_color; - *cursor_color = *text_color; - *text_color = swap; - } + *cursor_color = color_hex_to_pixman(term->cursor_color.cursor); + *text_color = color_hex_to_pixman(term->cursor_color.text); } else { *cursor_color = *fg; *text_color = *bg;