diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2019-11-28 18:22:21 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2019-11-28 18:22:21 +0000 |
| commit | b96fb2ddab64970783313850ed80dfd311c16158 (patch) | |
| tree | a0000616a81e97859d9f01bc944c4636e666dfda | |
| parent | async: first synchronous write may succeed partially (diff) | |
render: fix rendering of cursor when cell is reversed
When the user had configured the cursor color, we failed to
invert (reverse) the foreground and background color when the cursor
was on a cell with the 'reverse' attribute set.
| -rw-r--r-- | render.c | 32 |
1 files changed, 19 insertions, 13 deletions
@@ -202,12 +202,25 @@ render_cell(struct terminal *term, pixman_image_t *pix, bool block_cursor = has_cursor && term->cursor_style == CURSOR_BLOCK; bool is_selected = coord_is_selected(term, col, row); - uint32_t _fg = cell->attrs.have_fg - ? cell->attrs.fg - : !term->reverse ? term->colors.fg : term->colors.bg; - uint32_t _bg = cell->attrs.have_bg - ? cell->attrs.bg - : !term->reverse ? term->colors.bg : term->colors.fg; + uint32_t _fg = 0; + uint32_t _bg = 0; + + if (block_cursor && term->cursor_color.text >> 31) { + /* User configured cursor color overrides all attributes */ + assert(term->cursor_color.cursor >> 31); + + /* Slightly ugly... reverse here, since they'll be reversed again below */ + _fg = term->cursor_color.cursor; + _bg = term->cursor_color.text; + } else { + /* Use cell specific color, if set, otherwise the default colors (possible reversed) */ + _fg = cell->attrs.have_fg + ? cell->attrs.fg + : !term->reverse ? term->colors.fg : term->colors.bg; + _bg = cell->attrs.have_bg + ? cell->attrs.bg + : !term->reverse ? term->colors.bg : term->colors.fg; + } /* If *one* is set, we reverse */ if (block_cursor ^ cell->attrs.reverse ^ is_selected) { @@ -226,13 +239,6 @@ render_cell(struct terminal *term, pixman_image_t *pix, if (cell->attrs.dim) pixman_color_dim(&fg); - if (block_cursor && term->cursor_color.text >> 31) { - /* User configured cursor color overrides all attributes */ - assert(term->cursor_color.cursor >> 31); - fg = color_hex_to_pixman(term->cursor_color.text); - bg = color_hex_to_pixman(term->cursor_color.cursor); - } - if (term->is_searching && !is_selected) { pixman_color_dim_for_search(&fg); pixman_color_dim_for_search(&bg); |
