[wiki] [sites] [st][patch] create cursor-color patch || Kipras Melnikovas

From: <git_AT_suckless.org>
Date: Wed, 24 Feb 2021 03:18:36 +0100

commit dd6f420f7ac13c4ab155d23e21aab2a7d3010bf6
Author: Kipras Melnikovas <kipras_AT_kipras.org>
Date: Wed Feb 24 04:10:14 2021 +0200

    [st][patch] create cursor-color patch
    
    as outlines in the markdown file -- still needs improvements,
    and I'm not sure if I have experise to solve them -
    I'd appreciate your help!
    
    Signed-off-by: Kipras Melnikovas <kipras_AT_kipras.org>

diff --git a/st.suckless.org/patches/cursor-color/cursor-color.png b/st.suckless.org/patches/cursor-color/cursor-color.png
new file mode 100644
index 00000000..d5d41602
Binary files /dev/null and b/st.suckless.org/patches/cursor-color/cursor-color.png differ
diff --git a/st.suckless.org/patches/cursor-color/index.md b/st.suckless.org/patches/cursor-color/index.md
new file mode 100644
index 00000000..3cb3b92e
--- /dev/null
+++ b/st.suckless.org/patches/cursor-color/index.md
_AT_@ -0,0 +1,26 @@
+color-cursor
+============
+
+![](cursor-color.png)
+
+Description
+-----------
+Turns your cursor's background into whatever color the character you're currently on is (much like alacritty). Some say the effeect is very appealing:)
+
+Notes
+-----
+
+~~Might be~~ Is incomplete - I'm new and suggestions are very welcome!
+
+- Default cursor is not shown (e.g. in (neo)vim INSERT mode)
+- Probably not all cases yet covered
+- Magic numbers used - would probably be best to avoid
+- Performance degradation considerations?
+
+Download
+--------
+* [st-cursor-color-0.8.4.diff](st-cursor-color-0.8.4.diff)
+
+Authors
+-------
+* Kipras Melnikovas <kipras_AT_kipras.org>
diff --git a/st.suckless.org/patches/cursor-color/st-cursor-color-0.8.4.diff b/st.suckless.org/patches/cursor-color/st-cursor-color-0.8.4.diff
new file mode 100644
index 00000000..c7361eb2
--- /dev/null
+++ b/st.suckless.org/patches/cursor-color/st-cursor-color-0.8.4.diff
_AT_@ -0,0 +1,49 @@
+From 8cda64fed0308533a1e79da9f5bdf2593d25c885 Mon Sep 17 00:00:00 2001
+From: Kipras Melnikovas <kipras_AT_kipras.org>
+Date: Wed, 24 Feb 2021 03:54:42 +0200
+Subject: [PATCH] create initial color-version patch
+
+swaps cursor background with the character you're currently on,
+much like alacritty.
+
+still needs improvements
+
+Signed-off-by: Kipras Melnikovas <kipras_AT_kipras.org>
+---
+ x.c | 17 +++++++++++++++--
+ 1 file changed, 15 insertions(+), 2 deletions(-)
+
+diff --git a/x.c b/x.c
+index 120e495..5a013f8 100644
+--- a/x.c
++++ b/x.c
+_AT_@ -1517,11 +1517,24 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
+ if (selected(cx, cy)) {
+ g.fg = defaultfg;
+ g.bg = defaultrcs;
++ drawcol = dc.col[g.bg];
+ } else {
++ /** swap background, much like alacritty */
++ g.bg = g.fg;
+ g.fg = defaultbg;
+- g.bg = defaultcs;
++
++ /**
++ * There were times when the `g.fg` value (now updated to `g.bg)
++ * would jump to a very large one and opening e.g. neovim
++ * would cause a segfault, thus I'm arbitrarily picking this value
++ * and it seems to work, but it'd best if this was improved.
++ */
++ if (g.bg > 259) {
++ drawcol = dc.col[g.fg];
++ } else {
++ drawcol = dc.col[g.bg];
++ }
+ }
+- drawcol = dc.col[g.bg];
+ }
+
+ /* draw the new one */
+--
+2.30.1
+
Received on Wed Feb 24 2021 - 03:18:36 CET

This archive was generated by hypermail 2.3.0 : Wed Feb 24 2021 - 03:24:42 CET