From 8cda64fed0308533a1e79da9f5bdf2593d25c885 Mon Sep 17 00:00:00 2001 From: Kipras Melnikovas Date: Wed, 24 Feb 2021 03:54:42 +0200 Subject: [PATCH] create initial color-version patch swaps cursor background with the character you're currently on, much like alacritty. still needs improvements Signed-off-by: Kipras Melnikovas --- x.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/x.c b/x.c index 120e495..5a013f8 100644 --- a/x.c +++ b/x.c @@ -1517,11 +1517,24 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) if (selected(cx, cy)) { g.fg = defaultfg; g.bg = defaultrcs; + drawcol = dc.col[g.bg]; } else { + /** swap background, much like alacritty */ + g.bg = g.fg; g.fg = defaultbg; - g.bg = defaultcs; + + /** + * There were times when the `g.fg` value (now updated to `g.bg) + * would jump to a very large one and opening e.g. neovim + * would cause a segfault, thus I'm arbitrarily picking this value + * and it seems to work, but it'd best if this was improved. + */ + if (g.bg > 259) { + drawcol = dc.col[g.fg]; + } else { + drawcol = dc.col[g.bg]; + } } - drawcol = dc.col[g.bg]; } /* draw the new one */ -- 2.30.1