diff --git a/README.md b/README.md index b99f19c..ec7225a 100644 --- 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 index c100421..62f70dc 100644 --- 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 index e5b17a6..d694c8e 100644 --- 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 */