sites

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

st-solarized-both-0.8.1.diff (5907B)


      1 From 79a5f9a3f4a606db1aa1b591aa38d74e331e354a Mon Sep 17 00:00:00 2001
      2 From: Linh Nguyen <linhvng.2212@gmail.com>
      3 Date: Wed, 28 Mar 2018 11:46:26 -0400
      4 Subject: [PATCH] port st-solarized-both to 0.8.1
      5 
      6 ---
      7  config.def.h | 72 ++++++++++++++++++++++++++++++++++++------------------------
      8  st.h         |  1 +
      9  x.c          | 28 ++++++++++++++++++-----
     10  3 files changed, 66 insertions(+), 35 deletions(-)
     11 
     12 diff --git a/config.def.h b/config.def.h
     13 index 82b1b09..256662a 100644
     14 --- a/config.def.h
     15 +++ b/config.def.h
     16 @@ -84,31 +84,44 @@ 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 +	/* solarized dark */
     46 +	"#073642",  /*  0: black    */
     47 +	"#dc322f",  /*  1: red      */
     48 +	"#859900",  /*  2: green    */
     49 +	"#b58900",  /*  3: yellow   */
     50 +	"#268bd2",  /*  4: blue     */
     51 +	"#d33682",  /*  5: magenta  */
     52 +	"#2aa198",  /*  6: cyan     */
     53 +	"#eee8d5",  /*  7: white    */
     54 +	"#002b36",  /*  8: brblack  */
     55 +	"#cb4b16",  /*  9: brred    */
     56 +	"#586e75",  /* 10: brgreen  */
     57 +	"#657b83",  /* 11: bryellow */
     58 +	"#839496",  /* 12: brblue   */
     59 +	"#6c71c4",  /* 13: brmagenta*/
     60 +	"#93a1a1",  /* 14: brcyan   */
     61 +	"#fdf6e3",  /* 15: brwhite  */
     62 +};
     63 + 
     64 +/* Terminal colors for alternate (light) palette */
     65 +static const char *altcolorname[] = {
     66 +	/* solarized light */
     67 +	"#eee8d5",  /*  0: black    */
     68 +	"#dc322f",  /*  1: red      */
     69 +	"#859900",  /*  2: green    */
     70 +	"#b58900",  /*  3: yellow   */
     71 +	"#268bd2",  /*  4: blue     */
     72 +	"#d33682",  /*  5: magenta  */
     73 +	"#2aa198",  /*  6: cyan     */
     74 +	"#073642",  /*  7: white    */
     75 +	"#fdf6e3",  /*  8: brblack  */
     76 +	"#cb4b16",  /*  9: brred    */
     77 +	"#93a1a1",  /* 10: brgreen  */
     78 +	"#839496",  /* 11: bryellow */
     79 +	"#657b83",  /* 12: brblue   */
     80 +	"#6c71c4",  /* 13: brmagenta*/
     81 +	"#586e75",  /* 14: brcyan   */
     82 +	"#002b36",  /* 15: brwhite  */
     83  };
     84  
     85  
     86 @@ -116,10 +129,10 @@ static const char *colorname[] = {
     87   * Default colors (colorname index)
     88   * foreground, background, cursor, reverse cursor
     89   */
     90 -unsigned int defaultfg = 7;
     91 -unsigned int defaultbg = 0;
     92 -static unsigned int defaultcs = 256;
     93 -static unsigned int defaultrcs = 257;
     94 +unsigned int defaultfg = 12;
     95 +unsigned int defaultbg = 8;
     96 +static unsigned int defaultcs = 14;
     97 +static unsigned int defaultrcs = 15;
     98  
     99  /*
    100   * Default shape of cursor
    101 @@ -178,6 +191,7 @@ static Shortcut shortcuts[] = {
    102  	{ TERMMOD,              XK_Y,           selpaste,       {.i =  0} },
    103  	{ TERMMOD,              XK_Num_Lock,    numlock,        {.i =  0} },
    104  	{ TERMMOD,              XK_I,           iso14755,       {.i =  0} },
    105 +	{ XK_ANY_MOD,           XK_F6,          swapcolors,     {.i =  0} },
    106  };
    107  
    108  /*
    109 diff --git a/st.h b/st.h
    110 index dac64d8..7b0159d 100644
    111 --- a/st.h
    112 +++ b/st.h
    113 @@ -118,6 +118,7 @@ extern char *vtiden;
    114  extern char *worddelimiters;
    115  extern int allowaltscreen;
    116  extern char *termname;
    117 +extern int usealtcolors;
    118  extern unsigned int tabspaces;
    119  extern unsigned int defaultfg;
    120  extern unsigned int defaultbg;
    121 diff --git a/x.c b/x.c
    122 index c343ba2..47ef3e9 100644
    123 --- a/x.c
    124 +++ b/x.c
    125 @@ -53,6 +53,7 @@ static void clipcopy(const Arg *);
    126  static void clippaste(const Arg *);
    127  static void numlock(const Arg *);
    128  static void selpaste(const Arg *);
    129 +static void swapcolors(const Arg *);
    130  static void zoom(const Arg *);
    131  static void zoomabs(const Arg *);
    132  static void zoomreset(const Arg *);
    133 @@ -240,6 +241,8 @@ static char *opt_title = NULL;
    134  
    135  static int oldbutton = 3; /* button event on startup: 3 = release */
    136  
    137 +int usealtcolors = 0; /* 1 to use alternate palette */
    138 +
    139  void
    140  clipcopy(const Arg *dummy)
    141  {
    142 @@ -278,6 +281,14 @@ numlock(const Arg *dummy)
    143  	win.mode ^= MODE_NUMLOCK;
    144  }
    145  
    146 +void
    147 +swapcolors(const Arg *dummy)
    148 +{
    149 +	usealtcolors = !usealtcolors;
    150 +	xloadcols();
    151 +	redraw();
    152 +}
    153 +
    154  void
    155  zoom(const Arg *arg)
    156  {
    157 @@ -700,6 +711,11 @@ sixd_to_16bit(int x)
    158  	return x == 0 ? 0 : 0x3737 + 0x2828 * x;
    159  }
    160  
    161 +const char* getcolorname(int i)
    162 +{
    163 +    return (usealtcolors) ?  altcolorname[i] : colorname[i];
    164 +}
    165 +
    166  int
    167  xloadcolor(int i, const char *name, Color *ncolor)
    168  {
    169 @@ -718,7 +734,7 @@ xloadcolor(int i, const char *name, Color *ncolor)
    170  			return XftColorAllocValue(xw.dpy, xw.vis,
    171  			                          xw.cmap, &color, ncolor);
    172  		} else
    173 -			name = colorname[i];
    174 +			name = getcolorname(i);
    175  	}
    176  
    177  	return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
    178 @@ -731,7 +747,7 @@ xloadcols(void)
    179  	static int loaded;
    180  	Color *cp;
    181  
    182 -	dc.collen = MAX(LEN(colorname), 256);
    183 +	dc.collen = MAX(LEN(colorname), LEN(altcolorname));
    184  	dc.col = xmalloc(dc.collen * sizeof(Color));
    185  
    186  	if (loaded) {
    187 @@ -741,8 +757,8 @@ xloadcols(void)
    188  
    189  	for (i = 0; i < dc.collen; i++)
    190  		if (!xloadcolor(i, NULL, &dc.col[i])) {
    191 -			if (colorname[i])
    192 -				die("Could not allocate color '%s'\n", colorname[i]);
    193 +			if (getcolorname(i))
    194 +				die("Could not allocate color '%s'\n", getcolorname(i));
    195  			else
    196  				die("Could not allocate color %d\n", i);
    197  		}
    198 @@ -1079,13 +1095,13 @@ xinit(int cols, int rows)
    199  	cursor = XCreateFontCursor(xw.dpy, mouseshape);
    200  	XDefineCursor(xw.dpy, xw.win, cursor);
    201  
    202 -	if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
    203 +	if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousefg), &xmousefg) == 0) {
    204  		xmousefg.red   = 0xffff;
    205  		xmousefg.green = 0xffff;
    206  		xmousefg.blue  = 0xffff;
    207  	}
    208  
    209 -	if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) {
    210 +	if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousebg), &xmousebg) == 0) {
    211  		xmousebg.red   = 0x0000;
    212  		xmousebg.green = 0x0000;
    213  		xmousebg.blue  = 0x0000;
    214 -- 
    215 2.16.3
    216