st-flexipatch

My st-flexipatch configuration
git clone git://git.ethandl.dev/st-flexipatch
Log | Files | Refs | README | LICENSE

commit 884c62a0564d538491aeaf3b2bc1cded587ed13d
parent 6c428724766f86a9e67f34b465a563a0def91acb
Author: bakkeby <bakkeby@gmail.com>
Date:   Fri, 26 Feb 2021 14:33:03 +0100

Adding dynamic cursor color patch ref. #10

Diffstat:
MREADME.md | 5+++++
Mpatches.def.h | 5+++++
Mx.c | 20++++++++++++++++++++
3 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -15,6 +15,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the ### Changelog: +2021-02-26 - Added the dynamic cursor color patch + 2021-02-15 - Added the alpha gradient patch 2020-11-14 - Added the wide glyphs patch @@ -80,6 +82,9 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the - [disable-fonts](https://st.suckless.org/patches/disable_bold_italic_fonts/) - this patch adds the option of disabling bold/italic/roman fonts globally + - [dynamic-cursor-color](https://st.suckless.org/patches/dynamic-cursor-color/) + - this patch makes the cursor color the inverse of the current cell color + - [externalpipe](https://st.suckless.org/patches/externalpipe/) - this patch allows for eading and writing st's screen through a pipe, e.g. to pass info to dmenu diff --git a/patches.def.h b/patches.def.h @@ -79,6 +79,11 @@ */ #define DISABLE_ROMAN_FONTS_PATCH 0 +/* This patch makes the cursor color the inverse of the current cell color. + * https://st.suckless.org/patches/dynamic-cursor-color/ + */ +#define DYNAMIC_CURSOR_COLOR_PATCH 0 + /* Reading and writing st's screen through a pipe, e.g. pass info to dmenu. * https://st.suckless.org/patches/externalpipe/ */ diff --git a/x.c b/x.c @@ -1848,6 +1848,9 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) #endif // LIGATURES_PATCH { Color drawcol; + #if DYNAMIC_CURSOR_COLOR_PATCH + XRenderColor colbg; + #endif // DYNAMIC_CURSOR_COLOR_PATCH /* remove the old cursor */ if (selected(ox, oy)) @@ -1887,10 +1890,27 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) g.fg = defaultfg; g.bg = defaultrcs; } else { + #if DYNAMIC_CURSOR_COLOR_PATCH + g.bg = g.fg; + g.fg = defaultbg; + #else g.fg = defaultbg; g.bg = defaultcs; + #endif // DYNAMIC_CURSOR_COLOR_PATCH } + + #if DYNAMIC_CURSOR_COLOR_PATCH + if (IS_TRUECOL(g.bg)) { + colbg.alpha = 0xffff; + colbg.red = TRUERED(g.bg); + colbg.green = TRUEGREEN(g.bg); + colbg.blue = TRUEBLUE(g.bg); + XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg, &drawcol); + } else + drawcol = dc.col[g.bg]; + #else drawcol = dc.col[g.bg]; + #endif // DYNAMIC_CURSOR_COLOR_PATCH } /* draw the new one */