sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

st-selectioncolors-0.8.2.diff (2120B)


      1 From 33bf0cb9ad1f3941ecfd7c9f3902607dcabc6978 Mon Sep 17 00:00:00 2001
      2 From: aleks <aleks.stier@icloud.com>
      3 Date: Thu, 10 Oct 2019 23:22:38 +0200
      4 Subject: [PATCH] Add settings for selection-colors
      5 
      6 This patch adds the two color-settings *selectionfg* and *selectionbg* to
      7 config.def.h. Those define the fore- and background colors which are used when
      8 text on the screen is selected with the mouse. This removes the default
      9 behaviour which would simply reverse the colors.
     10 
     11 Additionally, a third setting *ingnoreselfg* exists. If true then the setting
     12 *selectionfg* is ignored and the original foreground-colors of each cell are
     13 not changed during selection. Basically only the background-color would change.
     14 This might be more visually appealing to some folks.
     15 ---
     16  config.def.h | 11 +++++++++--
     17  x.c          |  6 +++---
     18  2 files changed, 12 insertions(+), 5 deletions(-)
     19 
     20 diff --git a/config.def.h b/config.def.h
     21 index 0e01717..fbbb2a4 100644
     22 --- a/config.def.h
     23 +++ b/config.def.h
     24 @@ -108,7 +108,7 @@ static const char *colorname[] = {
     25  
     26  	/* more colors can be added after 255 to use with DefaultXX */
     27  	"#cccccc",
     28 -	"#555555",
     29 +	"#2e3440",
     30  };
     31  
     32  
     33 @@ -119,7 +119,14 @@ static const char *colorname[] = {
     34  unsigned int defaultfg = 7;
     35  unsigned int defaultbg = 0;
     36  static unsigned int defaultcs = 256;
     37 -static unsigned int defaultrcs = 257;
     38 +static unsigned int defaultrcs = 256;
     39 +
     40 +/* Colors used for selection */
     41 +unsigned int selectionbg = 257;
     42 +unsigned int selectionfg = 7;
     43 +/* If 0 use selectionfg as foreground in order to have a uniform foreground-color */
     44 +/* Else if 1 keep original foreground-color of each cell => more colors :) */
     45 +static int ignoreselfg = 1;
     46  
     47  /*
     48   * Default shape of cursor
     49 diff --git a/x.c b/x.c
     50 index 0422421..a001f2e 100644
     51 --- a/x.c
     52 +++ b/x.c
     53 @@ -1336,9 +1336,9 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
     54  	}
     55  
     56  	if (base.mode & ATTR_REVERSE) {
     57 -		temp = fg;
     58 -		fg = bg;
     59 -		bg = temp;
     60 +		bg = &dc.col[selectionbg];
     61 +		if (!ignoreselfg)
     62 +			fg = &dc.col[selectionfg];
     63  	}
     64  
     65  	if (base.mode & ATTR_BLINK && win.mode & MODE_BLINK)
     66 -- 
     67 2.23.0
     68