[wiki] [sites] st: add spoiler patch || dequis

From: <git_AT_suckless.org>
Date: Thu, 01 Oct 2015 08:11:58 +0200

commit 44f6c583dfd571caa64f41402d4ec54ae0ed828a
Author: dequis <dx_AT_dxzone.com.ar>
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
_AT_@ -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 - dx_AT_dxzone.com.ar
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
_AT_@ -0,0 +1,22 @@
+diff --git a/st.c b/st.c
+index b89d094..88c78f5 100644
+--- a/st.c
++++ b/st.c
+_AT_@ -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
_AT_@ -0,0 +1,22 @@
+diff --git a/st.c b/st.c
+index bcf74b3..0763f9f 100644
+--- a/st.c
++++ b/st.c
+_AT_@ -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) {
Received on Thu Oct 01 2015 - 08:11:58 CEST

This archive was generated by hypermail 2.3.0 : Thu Oct 01 2015 - 08:12:11 CEST