| st-solarized-both-0.8.3.diff - sites - public wiki contents of suckless.org | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| st-solarized-both-0.8.3.diff (5708B) | |
| --- | |
| 1 From a5a82d6a2efa04415043b7ea8eff16d90d5bf86a Mon Sep 17 00:00:00 2001 | |
| 2 From: =?UTF-8?q?Joachim=20B=C3=BCchel?= <[email protected]> | |
| 3 Date: Sun, 7 Jun 2020 13:22:18 +0200 | |
| 4 Subject: [PATCH] Solarized light and dark theme | |
| 5 | |
| 6 Port st-solarized-both to 0.8.3 | |
| 7 --- | |
| 8 config.def.h | 72 +++++++++++++++++++++++++++++++--------------------- | |
| 9 st.h | 1 + | |
| 10 x.c | 26 +++++++++++++++---- | |
| 11 3 files changed, 65 insertions(+), 34 deletions(-) | |
| 12 | |
| 13 diff --git a/config.def.h b/config.def.h | |
| 14 index 8a58f1c..1010a4f 100644 | |
| 15 --- a/config.def.h | |
| 16 +++ b/config.def.h | |
| 17 @@ -86,31 +86,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 @@ -118,10 +131,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 @@ -185,6 +198,7 @@ static Shortcut shortcuts[] = { | |
| 103 { TERMMOD, XK_Y, selpaste, {.i = … | |
| 104 { ShiftMask, XK_Insert, selpaste, {.i = … | |
| 105 { TERMMOD, XK_Num_Lock, numlock, {.i = … | |
| 106 + { XK_ANY_MOD, XK_F6, swapcolors, {.i = … | |
| 107 }; | |
| 108 | |
| 109 /* | |
| 110 diff --git a/st.h b/st.h | |
| 111 index d978458..606c302 100644 | |
| 112 --- a/st.h | |
| 113 +++ b/st.h | |
| 114 @@ -119,6 +119,7 @@ extern char *vtiden; | |
| 115 extern wchar_t *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 22c7dfc..5598fb6 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 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 @@ -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 @@ -748,6 +759,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 @@ -766,7 +782,7 @@ xloadcolor(int i, const char *name, Color *ncolor) | |
| 171 return XftColorAllocValue(xw.dpy, xw.vis, | |
| 172 xw.cmap, &color, ncol… | |
| 173 } else | |
| 174 - name = colorname[i]; | |
| 175 + name = getcolorname(i); | |
| 176 } | |
| 177 | |
| 178 return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor); | |
| 179 @@ -789,8 +805,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", … | |
| 185 + if (getcolorname(i)) | |
| 186 + die("could not allocate color '%s'\n", … | |
| 187 else | |
| 188 die("could not allocate color %d\n", i); | |
| 189 } | |
| 190 @@ -1169,13 +1185,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)… | |
| 195 + if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousefg), &xmouse… | |
| 196 xmousefg.red = 0xffff; | |
| 197 xmousefg.green = 0xffff; | |
| 198 xmousefg.blue = 0xffff; | |
| 199 } | |
| 200 | |
| 201 - if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg)… | |
| 202 + if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousebg), &xmouse… | |
| 203 xmousebg.red = 0x0000; | |
| 204 xmousebg.green = 0x0000; | |
| 205 xmousebg.blue = 0x0000; | |
| 206 -- | |
| 207 2.27.0 | |
| 208 |