Adding dynamic cursor color patch ref. #10

This commit is contained in:
bakkeby 2021-02-26 14:33:03 +01:00
parent 6c42872476
commit 884c62a056
3 changed files with 30 additions and 0 deletions

View File

@ -15,6 +15,8 @@ Refer to [https://st.suckless.org/](https://st.suckless.org/) for details on the
### Changelog: ### Changelog:
2021-02-26 - Added the dynamic cursor color patch
2021-02-15 - Added the alpha gradient patch 2021-02-15 - Added the alpha gradient patch
2020-11-14 - Added the wide glyphs 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/) - [disable-fonts](https://st.suckless.org/patches/disable_bold_italic_fonts/)
- this patch adds the option of disabling bold/italic/roman fonts globally - 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/) - [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 - this patch allows for eading and writing st's screen through a pipe, e.g. to pass info to dmenu

View File

@ -79,6 +79,11 @@
*/ */
#define DISABLE_ROMAN_FONTS_PATCH 0 #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. /* Reading and writing st's screen through a pipe, e.g. pass info to dmenu.
* https://st.suckless.org/patches/externalpipe/ * https://st.suckless.org/patches/externalpipe/
*/ */

20
x.c
View File

@ -1848,6 +1848,9 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
#endif // LIGATURES_PATCH #endif // LIGATURES_PATCH
{ {
Color drawcol; Color drawcol;
#if DYNAMIC_CURSOR_COLOR_PATCH
XRenderColor colbg;
#endif // DYNAMIC_CURSOR_COLOR_PATCH
/* remove the old cursor */ /* remove the old cursor */
if (selected(ox, oy)) 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.fg = defaultfg;
g.bg = defaultrcs; g.bg = defaultrcs;
} else { } else {
#if DYNAMIC_CURSOR_COLOR_PATCH
g.bg = g.fg;
g.fg = defaultbg;
#else
g.fg = defaultbg; g.fg = defaultbg;
g.bg = defaultcs; 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]; drawcol = dc.col[g.bg];
#endif // DYNAMIC_CURSOR_COLOR_PATCH
} }
/* draw the new one */ /* draw the new one */