st-solarized-both-20190128-3be4cf1.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
st-solarized-both-20190128-3be4cf1.diff (5987B)
---
1 From f50646447a9c7e82023d5795cd130e1b078cfbec Mon Sep 17 00:00:00 2001
2 From: Varun Iyer <varun_iyer@protonmail.ch>
3 Date: Mon, 28 Jan 2019 17:41:46 -0800
4 Subject: [PATCH] Fixed patch application for solarized light/dark
5
6 There were a few lines that had been changed; the patch now applies correctly to the most recent version of st.
7 ---
8 config.def.h | 72 +++++++++++++++++++++++++++++++---------------------
9 st.h | 1 +
10 x.c | 28 +++++++++++++++-----
11 3 files changed, 66 insertions(+), 35 deletions(-)
12
13 diff --git a/config.def.h b/config.def.h
14 index 0e01717..58b39b7 100644
15 --- a/config.def.h
16 +++ b/config.def.h
17 @@ -84,31 +84,44 @@ unsigned int tabspaces = 8;
18
19 /* Terminal colors (16 first used in escape sequence) */
20 static const char *colorname[] = {
21 - /* 8 normal colors */
22 - "black",
23 - "red3",
24 - "green3",
25 - "yellow3",
26 - "blue2",
27 - "magenta3",
28 - "cyan3",
29 - "gray90",
30 -
31 - /* 8 bright colors */
32 - "gray50",
33 - "red",
34 - "green",
35 - "yellow",
36 - "#5c5cff",
37 - "magenta",
38 - "cyan",
39 - "white",
40 -
41 - [255] = 0,
42 -
43 - /* more colors can be added after 255 to use with DefaultXX */
44 - "#cccccc",
45 - "#555555",
46 + /* solarized dark */
47 + "#073642", /* 0: black */
48 + "#dc322f", /* 1: red */
49 + "#859900", /* 2: green */
50 + "#b58900", /* 3: yellow */
51 + "#268bd2", /* 4: blue */
52 + "#d33682", /* 5: magenta */
53 + "#2aa198", /* 6: cyan */
54 + "#eee8d5", /* 7: white */
55 + "#002b36", /* 8: brblack */
56 + "#cb4b16", /* 9: brred */
57 + "#586e75", /* 10: brgreen */
58 + "#657b83", /* 11: bryellow */
59 + "#839496", /* 12: brblue */
60 + "#6c71c4", /* 13: brmagenta*/
61 + "#93a1a1", /* 14: brcyan */
62 + "#fdf6e3", /* 15: brwhite */
63 +};
64 +
65 +/* Terminal colors for alternate (light) palette */
66 +static const char *altcolorname[] = {
67 + /* solarized light */
68 + "#eee8d5", /* 0: black */
69 + "#dc322f", /* 1: red */
70 + "#859900", /* 2: green */
71 + "#b58900", /* 3: yellow */
72 + "#268bd2", /* 4: blue */
73 + "#d33682", /* 5: magenta */
74 + "#2aa198", /* 6: cyan */
75 + "#073642", /* 7: white */
76 + "#fdf6e3", /* 8: brblack */
77 + "#cb4b16", /* 9: brred */
78 + "#93a1a1", /* 10: brgreen */
79 + "#839496", /* 11: bryellow */
80 + "#657b83", /* 12: brblue */
81 + "#6c71c4", /* 13: brmagenta*/
82 + "#586e75", /* 14: brcyan */
83 + "#002b36", /* 15: brwhite */
84 };
85
86
87 @@ -116,10 +129,10 @@ static const char *colorname[] = {
88 * Default colors (colorname index)
89 * foreground, background, cursor, reverse cursor
90 */
91 -unsigned int defaultfg = 7;
92 -unsigned int defaultbg = 0;
93 -static unsigned int defaultcs = 256;
94 -static unsigned int defaultrcs = 257;
95 +unsigned int defaultfg = 12;
96 +unsigned int defaultbg = 8;
97 +static unsigned int defaultcs = 14;
98 +static unsigned int defaultrcs = 15;
99
100 /*
101 * Default shape of cursor
102 @@ -178,6 +191,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 38c61c4..941b5f8 100644
112 --- a/st.h
113 +++ b/st.h
114 @@ -117,6 +117,7 @@ extern char *vtiden;
115 extern char *worddelimiters;
116 extern int allowaltscreen;
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 0422421..ad158cf 100644
124 --- a/x.c
125 +++ b/x.c
126 @@ -53,6 +53,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 @@ -240,6 +241,8 @@ static char *opt_title = NULL;
135
136 static int oldbutton = 3; /* button event on startup: 3 = release */
137
138 +int usealtcolors = 0; /* 1 to use alternate palette */
139 +
140 void
141 clipcopy(const Arg *dummy)
142 {
143 @@ -278,6 +281,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 @@ -702,6 +713,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 @@ -720,7 +736,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 @@ -737,13 +753,13 @@ xloadcols(void)
180 for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp)
181 XftColorFree(xw.dpy, xw.vis, xw.cmap, cp);
182 } else {
183 - dc.collen = MAX(LEN(colorname), 256);
184 + dc.collen = MAX(LEN(colorname), LEN(altcolorname));
185 dc.col = xmalloc(dc.collen * sizeof(Color));
186 }
187
188 for (i = 0; i < dc.collen; i++)
189 if (!xloadcolor(i, NULL, &dc.col[i])) {
190 - if (colorname[i])
191 + if (getcolorname(i))
192 die("could not allocate color '%s'\n", colorname[i]);
193 else
194 die("could not allocate color %d\n", i);
195 @@ -1082,13 +1098,13 @@ xinit(int cols, int rows)
196 cursor = XCreateFontCursor(xw.dpy, mouseshape);
197 XDefineCursor(xw.dpy, xw.win, cursor);
198
199 - if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
200 + if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousefg), &xmousefg) == 0) {
201 xmousefg.red = 0xffff;
202 xmousefg.green = 0xffff;
203 xmousefg.blue = 0xffff;
204 }
205
206 - if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) {
207 + if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousebg), &xmousebg) == 0) {
208 xmousebg.red = 0x0000;
209 xmousebg.green = 0x0000;
210 xmousebg.blue = 0x0000;
211 --
212 2.20.1
213