sites

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

st-solarized-both-20220617-baa9357.diff (5695B)


      1 From f5a53a03f9ed6b8e1a764274eb9b0aed99319d6b Mon Sep 17 00:00:00 2001
      2 From: Max Schillinger <maxschillinger@web.de>
      3 Date: Fri, 17 Jun 2022 20:21:40 +0200
      4 Subject: [PATCH] solarized-both patch for st commit baa9357
      5 
      6 ---
      7  config.def.h | 73 ++++++++++++++++++++++++++++++----------------------
      8  st.h         |  1 +
      9  x.c          | 26 +++++++++++++++----
     10  3 files changed, 64 insertions(+), 36 deletions(-)
     11 
     12 diff --git a/config.def.h b/config.def.h
     13 index 91ab8ca..0c37a3a 100644
     14 --- a/config.def.h
     15 +++ b/config.def.h
     16 @@ -95,44 +95,54 @@ unsigned int tabspaces = 8;
     17  
     18  /* Terminal colors (16 first used in escape sequence) */
     19  static const char *colorname[] = {
     20 -	/* 8 normal colors */
     21 -	"black",
     22 -	"red3",
     23 -	"green3",
     24 -	"yellow3",
     25 -	"blue2",
     26 -	"magenta3",
     27 -	"cyan3",
     28 -	"gray90",
     29 -
     30 -	/* 8 bright colors */
     31 -	"gray50",
     32 -	"red",
     33 -	"green",
     34 -	"yellow",
     35 -	"#5c5cff",
     36 -	"magenta",
     37 -	"cyan",
     38 -	"white",
     39 -
     40 -	[255] = 0,
     41 -
     42 -	/* more colors can be added after 255 to use with DefaultXX */
     43 -	"#cccccc",
     44 -	"#555555",
     45 -	"gray90", /* default foreground colour */
     46 -	"black", /* default background colour */
     47 +	/* solarized dark */
     48 +	"#073642",  /*  0: black    */
     49 +	"#dc322f",  /*  1: red      */
     50 +	"#859900",  /*  2: green    */
     51 +	"#b58900",  /*  3: yellow   */
     52 +	"#268bd2",  /*  4: blue     */
     53 +	"#d33682",  /*  5: magenta  */
     54 +	"#2aa198",  /*  6: cyan     */
     55 +	"#eee8d5",  /*  7: white    */
     56 +	"#002b36",  /*  8: brblack  */
     57 +	"#cb4b16",  /*  9: brred    */
     58 +	"#586e75",  /* 10: brgreen  */
     59 +	"#657b83",  /* 11: bryellow */
     60 +	"#839496",  /* 12: brblue   */
     61 +	"#6c71c4",  /* 13: brmagenta*/
     62 +	"#93a1a1",  /* 14: brcyan   */
     63 +	"#fdf6e3",  /* 15: brwhite  */
     64  };
     65  
     66 +/* Terminal colors for alternate (light) palette */
     67 +static const char *altcolorname[] = {
     68 +	/* solarized light */
     69 +	"#eee8d5",  /*  0: black    */
     70 +	"#dc322f",  /*  1: red      */
     71 +	"#859900",  /*  2: green    */
     72 +	"#b58900",  /*  3: yellow   */
     73 +	"#268bd2",  /*  4: blue     */
     74 +	"#d33682",  /*  5: magenta  */
     75 +	"#2aa198",  /*  6: cyan     */
     76 +	"#073642",  /*  7: white    */
     77 +	"#fdf6e3",  /*  8: brblack  */
     78 +	"#cb4b16",  /*  9: brred    */
     79 +	"#93a1a1",  /* 10: brgreen  */
     80 +	"#839496",  /* 11: bryellow */
     81 +	"#657b83",  /* 12: brblue   */
     82 +	"#6c71c4",  /* 13: brmagenta*/
     83 +	"#586e75",  /* 14: brcyan   */
     84 +	"#002b36",  /* 15: brwhite  */
     85 +};
     86  
     87  /*
     88   * Default colors (colorname index)
     89   * foreground, background, cursor, reverse cursor
     90   */
     91 -unsigned int defaultfg = 258;
     92 -unsigned int defaultbg = 259;
     93 -unsigned int defaultcs = 256;
     94 -static unsigned int defaultrcs = 257;
     95 +unsigned int defaultfg = 12;
     96 +unsigned int defaultbg = 8;
     97 +unsigned int defaultcs = 14;
     98 +static unsigned int defaultrcs = 15;
     99  
    100  /*
    101   * Default shape of cursor
    102 @@ -201,6 +211,7 @@ static Shortcut shortcuts[] = {
    103  	{ TERMMOD,              XK_Y,           selpaste,       {.i =  0} },
    104  	{ ShiftMask,            XK_Insert,      selpaste,       {.i =  0} },
    105  	{ TERMMOD,              XK_Num_Lock,    numlock,        {.i =  0} },
    106 +	{ XK_ANY_MOD,           XK_F6,          swapcolors,     {.i =  0} },
    107  };
    108  
    109  /*
    110 diff --git a/st.h b/st.h
    111 index fd3b0d8..4b4d5ab 100644
    112 --- a/st.h
    113 +++ b/st.h
    114 @@ -120,6 +120,7 @@ extern wchar_t *worddelimiters;
    115  extern int allowaltscreen;
    116  extern int allowwindowops;
    117  extern char *termname;
    118 +extern int usealtcolors;
    119  extern unsigned int tabspaces;
    120  extern unsigned int defaultfg;
    121  extern unsigned int defaultbg;
    122 diff --git a/x.c b/x.c
    123 index 2a3bd38..144ed40 100644
    124 --- a/x.c
    125 +++ b/x.c
    126 @@ -55,6 +55,7 @@ static void clipcopy(const Arg *);
    127  static void clippaste(const Arg *);
    128  static void numlock(const Arg *);
    129  static void selpaste(const Arg *);
    130 +static void swapcolors(const Arg *);
    131  static void zoom(const Arg *);
    132  static void zoomabs(const Arg *);
    133  static void zoomreset(const Arg *);
    134 @@ -254,6 +255,8 @@ static char *opt_title = NULL;
    135  
    136  static uint buttons; /* bit field of pressed buttons */
    137  
    138 +int usealtcolors = 0; /* 1 to use alternate palette */
    139 +
    140  void
    141  clipcopy(const Arg *dummy)
    142  {
    143 @@ -292,6 +295,14 @@ numlock(const Arg *dummy)
    144  	win.mode ^= MODE_NUMLOCK;
    145  }
    146  
    147 +void
    148 +swapcolors(const Arg *dummy)
    149 +{
    150 + usealtcolors = !usealtcolors;
    151 + xloadcols();
    152 + redraw();
    153 +}
    154 +
    155  void
    156  zoom(const Arg *arg)
    157  {
    158 @@ -766,6 +777,11 @@ sixd_to_16bit(int x)
    159  	return x == 0 ? 0 : 0x3737 + 0x2828 * x;
    160  }
    161  
    162 +const char* getcolorname(int i)
    163 +{
    164 +    return (usealtcolors) ?  altcolorname[i] : colorname[i];
    165 +}
    166 +
    167  int
    168  xloadcolor(int i, const char *name, Color *ncolor)
    169  {
    170 @@ -784,7 +800,7 @@ xloadcolor(int i, const char *name, Color *ncolor)
    171  			return XftColorAllocValue(xw.dpy, xw.vis,
    172  			                          xw.cmap, &color, ncolor);
    173  		} else
    174 -			name = colorname[i];
    175 +			name = getcolorname(i);
    176  	}
    177  
    178  	return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
    179 @@ -807,8 +823,8 @@ xloadcols(void)
    180  
    181  	for (i = 0; i < dc.collen; i++)
    182  		if (!xloadcolor(i, NULL, &dc.col[i])) {
    183 -			if (colorname[i])
    184 -				die("could not allocate color '%s'\n", colorname[i]);
    185 +			if (getcolorname(i))
    186 +				die("could not allocate color '%s'\n", getcolorname(i));
    187  			else
    188  				die("could not allocate color %d\n", i);
    189  		}
    190 @@ -1200,13 +1216,13 @@ xinit(int cols, int rows)
    191  	cursor = XCreateFontCursor(xw.dpy, mouseshape);
    192  	XDefineCursor(xw.dpy, xw.win, cursor);
    193  
    194 -	if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
    195 +	if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousefg), &xmousefg) == 0) {
    196  		xmousefg.red   = 0xffff;
    197  		xmousefg.green = 0xffff;
    198  		xmousefg.blue  = 0xffff;
    199  	}
    200  
    201 -	if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) {
    202 +	if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousebg), &xmousebg) == 0) {
    203  		xmousebg.red   = 0x0000;
    204  		xmousebg.green = 0x0000;
    205  		xmousebg.blue  = 0x0000;
    206 -- 
    207 2.36.1
    208