aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-23 16:54:58 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-23 16:54:58 +0000
commitbf4847d3e028516b0de446e8455d43833983c17b (patch)
tree0b3dfa5627bffec22e87db85928aef7c6a59c14e /render.c
parentcsi: ignore CSI ?1036h/l (metaSendsEscape) (diff)
conf: allow the user to configure a fixed cursor color
The default is to reverse the foreground/background colors in the cell with the cursor. But, if the user configures a specific set of cursor colors, those will always be used, regardless of other cell attributes (dim, reverse etc). The cursor color is specified as two color values, 'text' and 'cursor'. The block cursor uses the 'cursor' color as background, and the 'text' color for the glyph. All other cursor styles uses the 'cursor' color for the cursor, but uses the cell's foreground color for the glyph (meaning, dim/reverse/etc applies).
Diffstat (limited to 'render.c')
-rw-r--r--render.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/render.c b/render.c
index 3e5730e0..16bc19b9 100644
--- a/render.c
+++ b/render.c
@@ -194,6 +194,13 @@ render_cell(struct terminal *term, struct buffer *buf, const struct cell *cell,
if (cell->attrs.dim)
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_rgb(term->cursor_color.text);
+ bg = color_hex_to_rgb(term->cursor_color.cursor);
+ }
+
/* Background */
cairo_set_source_rgb(buf->cairo, bg.r, bg.g, bg.b);
cairo_rectangle(buf->cairo, x, y, width, height);
@@ -201,11 +208,12 @@ render_cell(struct terminal *term, struct buffer *buf, const struct cell *cell,
/* Non-block cursors */
if (has_cursor) {
+ struct rgb cursor_color = color_hex_to_rgb(term->cursor_color.cursor);
if (term->cursor_style == CURSOR_BAR)
- draw_bar(term, buf, fg, x, y);
+ draw_bar(term, buf, cursor_color, x, y);
else if (term->cursor_style == CURSOR_UNDERLINE)
draw_underline(
- term, buf, attrs_to_font(term, &cell->attrs), fg, x, y);
+ term, buf, attrs_to_font(term, &cell->attrs), cursor_color, x, y);
}
if (cell->attrs.blink && !term->blink.active) {