commit 44f6c583dfd571caa64f41402d4ec54ae0ed828a
Author: dequis <[email protected]>
Date:   Thu Oct 1 02:09:23 2015 -0300

    st: add spoiler patch
    
    To use inverted defaultbg/fg for selection when bg/fg are the same

diff --git a/st.suckless.org/patches/spoiler.md 
b/st.suckless.org/patches/spoiler.md
new file mode 100644
index 0000000..1aabb35
--- /dev/null
+++ b/st.suckless.org/patches/spoiler.md
@@ -0,0 +1,28 @@
+spoiler
+=======
+
+Description
+-----------
+
+Use inverted defaultbg/fg for selection when bg/fg are the same
+
+The background/foreground of selected text is currently set by setting
+ATTR_REVERSE, which flips its normal bg/fg. When the text being selected
+has the same bg and fg, it won't be readable after selecting it, either.
+
+My main use case is black-on-black text used to mark 'spoilers'.
+
+This patch allows that text to be read by selecting it, turning it into
+text with white bg and black fg (given default values for defaultbg/fg),
+just like most normal unformatted text when selected.
+
+Download
+--------
+
+ * [st-git-20150922-spoiler.diff](st-git-20150922-spoiler.diff)
+ * [st-0.6-spoiler.diff](st-0.6-spoiler.diff)
+
+Authors
+-------
+
+ * dequis - [email protected]
diff --git a/st.suckless.org/patches/st-0.6-spoiler.diff 
b/st.suckless.org/patches/st-0.6-spoiler.diff
new file mode 100644
index 0000000..5c1da8f
--- /dev/null
+++ b/st.suckless.org/patches/st-0.6-spoiler.diff
@@ -0,0 +1,22 @@
+diff --git a/st.c b/st.c
+index b89d094..88c78f5 100644
+--- a/st.c
++++ b/st.c
+@@ -3483,9 +3483,14 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, 
Glyph base, int len, int x, i
+       }
+ 
+       if(base.mode & ATTR_REVERSE) {
+-              temp = fg;
+-              fg = bg;
+-              bg = temp;
++              if (bg == fg) {
++                      bg = &dc.col[defaultfg];
++                      fg = &dc.col[defaultbg];
++              } else {
++                      temp = fg;
++                      fg = bg;
++                      bg = temp;
++              }
+       }
+ 
+       if((base.mode & ATTR_BOLD_FAINT) == ATTR_FAINT) {
diff --git a/st.suckless.org/patches/st-git-20150922-spoiler.diff 
b/st.suckless.org/patches/st-git-20150922-spoiler.diff
new file mode 100644
index 0000000..051a820
--- /dev/null
+++ b/st.suckless.org/patches/st-git-20150922-spoiler.diff
@@ -0,0 +1,22 @@
+diff --git a/st.c b/st.c
+index bcf74b3..0763f9f 100644
+--- a/st.c
++++ b/st.c
+@@ -3752,9 +3752,14 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, 
Glyph base, int len, int x, i
+       }
+ 
+       if (base.mode & ATTR_REVERSE) {
+-              temp = fg;
+-              fg = bg;
+-              bg = temp;
++              if (bg == fg) {
++                      bg = &dc.col[defaultfg];
++                      fg = &dc.col[defaultbg];
++              } else {
++                      temp = fg;
++                      fg = bg;
++                      bg = temp;
++              }
+       }
+ 
+       if ((base.mode & ATTR_BOLD_FAINT) == ATTR_FAINT) {


Reply via email to