sites

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

st-solarized-both-0.8.4.diff (5214B)


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