sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

st-dynamic-cursor-color-0.9.diff (1221B)


      1 From 215ec30d6b5fe3319f88f1c9d16a37b6e14e5a53 Mon Sep 17 00:00:00 2001
      2 From: Bakkeby <bakkeby@gmail.com>
      3 Date: Mon, 19 Dec 2022 10:20:47 +0100
      4 Subject: [PATCH] dynamic cursor color: cursor color taken from current
      5  character
      6 
      7 ---
      8  x.c | 17 ++++++++++++++---
      9  1 file changed, 14 insertions(+), 3 deletions(-)
     10 
     11 diff --git a/x.c b/x.c
     12 index 2a3bd38..21aadce 100644
     13 --- a/x.c
     14 +++ b/x.c
     15 @@ -1520,6 +1520,7 @@ void
     16  xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
     17  {
     18  	Color drawcol;
     19 +	XRenderColor colbg;
     20  
     21  	/* remove the old cursor */
     22  	if (selected(ox, oy))
     23 @@ -1548,11 +1549,21 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
     24  		if (selected(cx, cy)) {
     25  			g.fg = defaultfg;
     26  			g.bg = defaultrcs;
     27 +		} else if (!(og.mode & ATTR_REVERSE)) {
     28 +			unsigned long col = g.bg;
     29 +			g.bg = g.fg;
     30 +			g.fg = col;
     31 +		}
     32 +
     33 +		if (IS_TRUECOL(g.bg)) {
     34 +			colbg.alpha = 0xffff;
     35 +			colbg.red = TRUERED(g.bg);
     36 +			colbg.green = TRUEGREEN(g.bg);
     37 +			colbg.blue = TRUEBLUE(g.bg);
     38 +			XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg, &drawcol);
     39  		} else {
     40 -			g.fg = defaultbg;
     41 -			g.bg = defaultcs;
     42 +			drawcol = dc.col[g.bg];
     43  		}
     44 -		drawcol = dc.col[g.bg];
     45  	}
     46  
     47  	/* draw the new one */
     48 -- 
     49 2.38.1
     50