st-cursor-color-0.8.4.diff (1293B)
1 From 8cda64fed0308533a1e79da9f5bdf2593d25c885 Mon Sep 17 00:00:00 2001 2 From: Kipras Melnikovas <kipras@kipras.org> 3 Date: Wed, 24 Feb 2021 03:54:42 +0200 4 Subject: [PATCH] create initial color-version patch 5 6 swaps cursor background with the character you're currently on, 7 much like alacritty. 8 9 still needs improvements 10 11 Signed-off-by: Kipras Melnikovas <kipras@kipras.org> 12 --- 13 x.c | 17 +++++++++++++++-- 14 1 file changed, 15 insertions(+), 2 deletions(-) 15 16 diff --git a/x.c b/x.c 17 index 120e495..5a013f8 100644 18 --- a/x.c 19 +++ b/x.c 20 @@ -1517,11 +1517,24 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) 21 if (selected(cx, cy)) { 22 g.fg = defaultfg; 23 g.bg = defaultrcs; 24 + drawcol = dc.col[g.bg]; 25 } else { 26 + /** swap background, much like alacritty */ 27 + g.bg = g.fg; 28 g.fg = defaultbg; 29 - g.bg = defaultcs; 30 + 31 + /** 32 + * There were times when the `g.fg` value (now updated to `g.bg) 33 + * would jump to a very large one and opening e.g. neovim 34 + * would cause a segfault, thus I'm arbitrarily picking this value 35 + * and it seems to work, but it'd best if this was improved. 36 + */ 37 + if (g.bg > 259) { 38 + drawcol = dc.col[g.fg]; 39 + } else { 40 + drawcol = dc.col[g.bg]; 41 + } 42 } 43 - drawcol = dc.col[g.bg]; 44 } 45 46 /* draw the new one */ 47 -- 48 2.30.1 49