Skip to content

Commit ef76eb2

Browse files
committed
[nat] solarized both
1 parent 6bc26d1 commit ef76eb2

File tree

3 files changed

+64
-36
lines changed

3 files changed

+64
-36
lines changed

config.def.h

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -107,44 +107,54 @@ unsigned int tabspaces = 8;
107107

108108
/* Terminal colors (16 first used in escape sequence) */
109109
static const char *colorname[] = {
110-
/* 8 normal colors */
111-
"black",
112-
"red3",
113-
"green3",
114-
"yellow3",
115-
"blue2",
116-
"magenta3",
117-
"cyan3",
118-
"gray90",
119-
120-
/* 8 bright colors */
121-
"gray50",
122-
"red",
123-
"green",
124-
"yellow",
125-
"#5c5cff",
126-
"magenta",
127-
"cyan",
128-
"white",
129-
130-
[255] = 0,
131-
132-
/* more colors can be added after 255 to use with DefaultXX */
133-
"#cccccc",
134-
"#555555",
135-
"gray90", /* default foreground colour */
136-
"black", /* default background colour */
110+
/* solarized dark */
111+
"#073642", /* 0: black */
112+
"#dc322f", /* 1: red */
113+
"#859900", /* 2: green */
114+
"#b58900", /* 3: yellow */
115+
"#268bd2", /* 4: blue */
116+
"#d33682", /* 5: magenta */
117+
"#2aa198", /* 6: cyan */
118+
"#eee8d5", /* 7: white */
119+
"#002b36", /* 8: brblack */
120+
"#cb4b16", /* 9: brred */
121+
"#586e75", /* 10: brgreen */
122+
"#657b83", /* 11: bryellow */
123+
"#839496", /* 12: brblue */
124+
"#6c71c4", /* 13: brmagenta*/
125+
"#93a1a1", /* 14: brcyan */
126+
"#fdf6e3", /* 15: brwhite */
137127
};
138128

129+
/* Terminal colors for alternate (light) palette */
130+
static const char *altcolorname[] = {
131+
/* solarized light */
132+
"#eee8d5", /* 0: black */
133+
"#dc322f", /* 1: red */
134+
"#859900", /* 2: green */
135+
"#b58900", /* 3: yellow */
136+
"#268bd2", /* 4: blue */
137+
"#d33682", /* 5: magenta */
138+
"#2aa198", /* 6: cyan */
139+
"#073642", /* 7: white */
140+
"#fdf6e3", /* 8: brblack */
141+
"#cb4b16", /* 9: brred */
142+
"#93a1a1", /* 10: brgreen */
143+
"#839496", /* 11: bryellow */
144+
"#657b83", /* 12: brblue */
145+
"#6c71c4", /* 13: brmagenta*/
146+
"#586e75", /* 14: brcyan */
147+
"#002b36", /* 15: brwhite */
148+
};
139149

140150
/*
141151
* Default colors (colorname index)
142152
* foreground, background, cursor, reverse cursor
143153
*/
144-
unsigned int defaultfg = 258;
145-
unsigned int defaultbg = 259;
146-
unsigned int defaultcs = 256;
147-
static unsigned int defaultrcs = 257;
154+
unsigned int defaultfg = 12;
155+
unsigned int defaultbg = 8;
156+
unsigned int defaultcs = 14;
157+
static unsigned int defaultrcs = 15;
148158

149159
/*
150160
* Default shape of cursor
@@ -219,6 +229,7 @@ static Shortcut shortcuts[] = {
219229
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
220230
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
221231
{ TERMMOD, XK_I, iso14755, {.i = 0} },
232+
{ XK_ANY_MOD, XK_F6, swapcolors, {.i = 0} },
222233
};
223234

224235
/*

st.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ extern wchar_t *worddelimiters;
130130
extern int allowaltscreen;
131131
extern int allowwindowops;
132132
extern char *termname;
133+
extern int usealtcolors;
133134
extern unsigned int tabspaces;
134135
extern unsigned int defaultfg;
135136
extern unsigned int defaultbg;

x.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ static void clipcopy(const Arg *);
5555
static void clippaste(const Arg *);
5656
static void numlock(const Arg *);
5757
static void selpaste(const Arg *);
58+
static void swapcolors(const Arg *);
5859
static void zoom(const Arg *);
5960
static void zoomabs(const Arg *);
6061
static void zoomreset(const Arg *);
@@ -255,6 +256,8 @@ static char *opt_title = NULL;
255256

256257
static uint buttons; /* bit field of pressed buttons */
257258

259+
int usealtcolors = 0; /* 1 to use alternate palette */
260+
258261
void
259262
clipcopy(const Arg *dummy)
260263
{
@@ -293,6 +296,14 @@ numlock(const Arg *dummy)
293296
win.mode ^= MODE_NUMLOCK;
294297
}
295298

299+
void
300+
swapcolors(const Arg *dummy)
301+
{
302+
usealtcolors = !usealtcolors;
303+
xloadcols();
304+
redraw();
305+
}
306+
296307
void
297308
zoom(const Arg *arg)
298309
{
@@ -770,6 +781,11 @@ sixd_to_16bit(int x)
770781
return x == 0 ? 0 : 0x3737 + 0x2828 * x;
771782
}
772783

784+
const char* getcolorname(int i)
785+
{
786+
return (usealtcolors) ? altcolorname[i] : colorname[i];
787+
}
788+
773789
int
774790
xloadcolor(int i, const char *name, Color *ncolor)
775791
{
@@ -788,7 +804,7 @@ xloadcolor(int i, const char *name, Color *ncolor)
788804
return XftColorAllocValue(xw.dpy, xw.vis,
789805
xw.cmap, &color, ncolor);
790806
} else
791-
name = colorname[i];
807+
name = getcolorname(i);
792808
}
793809

794810
return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
@@ -811,8 +827,8 @@ xloadcols(void)
811827

812828
for (i = 0; i < dc.collen; i++)
813829
if (!xloadcolor(i, NULL, &dc.col[i])) {
814-
if (colorname[i])
815-
die("could not allocate color '%s'\n", colorname[i]);
830+
if (getcolorname(i))
831+
die("could not allocate color '%s'\n", getcolorname(i));
816832
else
817833
die("could not allocate color %d\n", i);
818834
}
@@ -1204,13 +1220,13 @@ xinit(int cols, int rows)
12041220
cursor = XCreateFontCursor(xw.dpy, mouseshape);
12051221
XDefineCursor(xw.dpy, xw.win, cursor);
12061222

1207-
if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
1223+
if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousefg), &xmousefg) == 0) {
12081224
xmousefg.red = 0xffff;
12091225
xmousefg.green = 0xffff;
12101226
xmousefg.blue = 0xffff;
12111227
}
12121228

1213-
if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) {
1229+
if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousebg), &xmousebg) == 0) {
12141230
xmousebg.red = 0x0000;
12151231
xmousebg.green = 0x0000;
12161232
xmousebg.blue = 0x0000;

0 commit comments

Comments
 (0)