[wiki] [sites] [st][patch][selectioncolors] Fixed bugs in and improved styling of 0.8.4 patch || Ashish Kumar Yadav

From: <git_AT_suckless.org>
Date: Sat, 31 Jul 2021 18:56:47 +0200

commit 595a518a74daac31b2bb958f974418dee85f511c
Author: Ashish Kumar Yadav <ashishkumar.yadav_AT_students.iiserpune.ac.in>
Date: Sat Jul 31 22:26:40 2021 +0530

    [st][patch][selectioncolors] Fixed bugs in and improved styling of 0.8.4 patch

diff --git a/st.suckless.org/patches/selectioncolors/st-selectioncolors-0.8.4.diff b/st.suckless.org/patches/selectioncolors/st-selectioncolors-0.8.4.diff
index dac9a5f5..4a8ef013 100644
--- a/st.suckless.org/patches/selectioncolors/st-selectioncolors-0.8.4.diff
+++ b/st.suckless.org/patches/selectioncolors/st-selectioncolors-0.8.4.diff
_AT_@ -1,7 +1,28 @@
-diff -up st-0.8.4-ori/config.def.h st-0.8.4/config.def.h
---- st-0.8.4-ori/config.def.h 2020-06-19 14:59:45.000000000 +0530
-+++ st-0.8.4/config.def.h 2020-07-20 19:39:32.310996650 +0530
-_AT_@ -119,7 +119,7 @@ static const char *colorname[] = {
+From 0750c0b8c91579ec871c70c8990527bebc86a56e Mon Sep 17 00:00:00 2001
+From: Ashish Kumar Yadav <ashishkumar.yadav_AT_students.iiserpune.ac.in>
+Date: Sat, 31 Jul 2021 22:21:11 +0530
+Subject: [PATCH] Add settings for selection-colors
+
+This patch adds the two color-settings *selectionfg* and *selectionbg* to
+config.def.h. Those define the fore- and background colors which are used when
+text on the screen is selected with the mouse. This removes the default
+behaviour which would simply reverse the colors.
+
+Additionally, a third setting *ingnoreselfg* exists. If true then the setting
+*selectionfg* is ignored and the original foreground-colors of each cell are
+not changed during selection. Basically only the background-color would change.
+This might be more visually appealing to some folks.
+---
+ config.def.h | 11 ++++++++---
+ st.h | 1 +
+ x.c | 30 +++++++++++++-----------------
+ 3 files changed, 22 insertions(+), 20 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 6f05dce..3679af8 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -119,18 +119,23 @@ static const char *colorname[] = {
  
          /* more colors can be added after 255 to use with DefaultXX */
          "#cccccc",
_AT_@ -10,14 +31,16 @@ diff -up st-0.8.4-ori/config.def.h st-0.8.4/config.def.h
  };
  
  
-_AT_@ -130,7 +130,14 @@ static const char *colorname[] = {
+ /*
+ * Default colors (colorname index)
+- * foreground, background, cursor, reverse cursor
++ * foreground, background, cursor, reverse cursor, selection
+ */
  unsigned int defaultfg = 7;
  unsigned int defaultbg = 0;
  static unsigned int defaultcs = 256;
 -static unsigned int defaultrcs = 257;
 +static unsigned int defaultrcs = 256;
-+
-+/* Colors used for selection */
 +unsigned int selectionbg = 257;
 +unsigned int selectionfg = 7;
 +/* If 0 use selectionfg as foreground in order to have a uniform foreground-color */
_AT_@ -26,21 +49,23 @@ diff -up st-0.8.4-ori/config.def.h st-0.8.4/config.def.h
  
  /*
   * Default shape of cursor
-diff -up st-0.8.4-ori/st.h st-0.8.4/st.h
---- st-0.8.4-ori/st.h 2020-06-19 14:59:45.000000000 +0530
-+++ st-0.8.4/st.h 2020-07-20 19:39:32.310996650 +0530
+diff --git a/st.h b/st.h
+index 3d351b6..e1a28c3 100644
+--- a/st.h
++++ b/st.h
 _AT_@ -33,6 +33,7 @@ enum glyph_attribute {
          ATTR_WRAP = 1 << 8,
          ATTR_WIDE = 1 << 9,
          ATTR_WDUMMY = 1 << 10,
-+ ATTR_SELECTED = 1 << 11,
++ ATTR_SELECTED = 1 << 11,
          ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
  };
  
-diff -up st-0.8.4-ori/x.c st-0.8.4/x.c
---- st-0.8.4-ori/x.c 2020-06-19 14:59:45.000000000 +0530
-+++ st-0.8.4/x.c 2020-07-20 19:46:23.081759264 +0530
-_AT_@ -1425,6 +1425,12 @@ xdrawglyphfontspecs(const XftGlyphFontSp
+diff --git a/x.c b/x.c
+index 210f184..7a6c70e 100644
+--- a/x.c
++++ b/x.c
+_AT_@ -1425,6 +1425,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
                  bg = temp;
          }
  
_AT_@ -53,20 +78,20 @@ diff -up st-0.8.4-ori/x.c st-0.8.4/x.c
          if (base.mode & ATTR_BLINK && win.mode & MODE_BLINK)
                  fg = bg;
  
-_AT_@ -1491,7 +1497,7 @@ xdrawcursor(int cx, int cy, Glyph g, int
+_AT_@ -1491,7 +1497,7 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
  
          /* remove the old cursor */
          if (selected(ox, oy))
 - og.mode ^= ATTR_REVERSE;
-+ og.mode ^= ATTR_SELECTED;
++ og.mode |= ATTR_SELECTED;
          xdrawglyph(og, ox, oy);
  
          if (IS_SET(MODE_HIDE))
-_AT_@ -1504,23 +1510,13 @@ xdrawcursor(int cx, int cy, Glyph g, int
+_AT_@ -1504,23 +1510,13 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
  
          if (IS_SET(MODE_REVERSE)) {
                  g.mode |= ATTR_REVERSE;
-+ g.fg = defaultcs;
++ g.fg = defaultcs;
                  g.bg = defaultfg;
 - if (selected(cx, cy)) {
 - drawcol = dc.col[defaultcs];
_AT_@ -75,7 +100,7 @@ diff -up st-0.8.4-ori/x.c st-0.8.4/x.c
 - drawcol = dc.col[defaultrcs];
 - g.fg = defaultcs;
 - }
-+ drawcol = dc.col[defaultrcs];
++ drawcol = dc.col[defaultrcs];
          } else {
 - if (selected(cx, cy)) {
 - g.fg = defaultfg;
_AT_@ -85,18 +110,21 @@ diff -up st-0.8.4-ori/x.c st-0.8.4/x.c
 - g.bg = defaultcs;
 - }
 - drawcol = dc.col[g.bg];
-+ g.fg = defaultbg;
-+ g.bg = defaultcs;
-+ drawcol = dc.col[defaultcs];
++ g.fg = defaultbg;
++ g.bg = defaultcs;
++ drawcol = dc.col[defaultcs];
          }
  
          /* draw the new one */
-_AT_@ -1612,7 +1608,7 @@ xdrawline(Line line, int x1, int y1, int
+_AT_@ -1612,7 +1608,7 @@ xdrawline(Line line, int x1, int y1, int x2)
                  if (new.mode == ATTR_WDUMMY)
                          continue;
                  if (selected(x, y1))
 - new.mode ^= ATTR_REVERSE;
-+ new.mode ^= ATTR_SELECTED;
++ new.mode |= ATTR_SELECTED;
                  if (i > 0 && ATTRCMP(base, new)) {
                          xdrawglyphfontspecs(specs, base, i, ox, y1);
                          specs += i;
+--
+2.32.0
+
Received on Sat Jul 31 2021 - 18:56:47 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 31 2021 - 19:00:46 CEST