st-dynamic-cursor-color-0.9.diff 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. x.c | 17 ++++++++++++++---
  8. 1 file changed, 14 insertions(+), 3 deletions(-)
  9. diff --git a/x.c b/x.c
  10. index 2a3bd38..21aadce 100644
  11. --- a/x.c
  12. +++ b/x.c
  13. @@ -1520,6 +1520,7 @@ void
  14. xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
  15. {
  16. Color drawcol;
  17. + XRenderColor colbg;
  18. /* remove the old cursor */
  19. if (selected(ox, oy))
  20. @@ -1548,11 +1549,21 @@ 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. + } else if (!(og.mode & ATTR_REVERSE)) {
  25. + unsigned long col = g.bg;
  26. + g.bg = g.fg;
  27. + g.fg = col;
  28. + }
  29. +
  30. + if (IS_TRUECOL(g.bg)) {
  31. + colbg.alpha = 0xffff;
  32. + colbg.red = TRUERED(g.bg);
  33. + colbg.green = TRUEGREEN(g.bg);
  34. + colbg.blue = TRUEBLUE(g.bg);
  35. + XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg, &drawcol);
  36. } else {
  37. - g.fg = defaultbg;
  38. - g.bg = defaultcs;
  39. + drawcol = dc.col[g.bg];
  40. }
  41. - drawcol = dc.col[g.bg];
  42. }
  43. /* draw the new one */
  44. --
  45. 2.38.1