st-solarized-both-0.9.3.diff (5336B)
1 diff --git a/config.def.h b/config.def.h 2 index 2cd740a..d8d029a 100644 3 --- a/config.def.h 4 +++ b/config.def.h 5 @@ -95,33 +95,44 @@ 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 - "gray90", /* default foreground colour */ 35 - "black", /* default background colour */ 36 + /* solarized dark */ 37 + "#073642", /* 0: black */ 38 + "#dc322f", /* 1: red */ 39 + "#859900", /* 2: green */ 40 + "#b58900", /* 3: yellow */ 41 + "#268bd2", /* 4: blue */ 42 + "#d33682", /* 5: magenta */ 43 + "#2aa198", /* 6: cyan */ 44 + "#eee8d5", /* 7: white */ 45 + "#002b36", /* 8: brblack */ 46 + "#cb4b16", /* 9: brred */ 47 + "#586e75", /* 10: brgreen */ 48 + "#657b83", /* 11: bryellow */ 49 + "#839496", /* 12: brblue */ 50 + "#6c71c4", /* 13: brmagenta*/ 51 + "#93a1a1", /* 14: brcyan */ 52 + "#fdf6e3", /* 15: brwhite */ 53 +}; 54 + 55 +/* Terminal colors for alternate (light) palette */ 56 +static const char *altcolorname[] = { 57 + /* solarized light */ 58 + "#eee8d5", /* 0: black */ 59 + "#dc322f", /* 1: red */ 60 + "#859900", /* 2: green */ 61 + "#b58900", /* 3: yellow */ 62 + "#268bd2", /* 4: blue */ 63 + "#d33682", /* 5: magenta */ 64 + "#2aa198", /* 6: cyan */ 65 + "#073642", /* 7: white */ 66 + "#fdf6e3", /* 8: brblack */ 67 + "#cb4b16", /* 9: brred */ 68 + "#93a1a1", /* 10: brgreen */ 69 + "#839496", /* 11: bryellow */ 70 + "#657b83", /* 12: brblue */ 71 + "#6c71c4", /* 13: brmagenta*/ 72 + "#586e75", /* 14: brcyan */ 73 + "#002b36", /* 15: brwhite */ 74 }; 75 76 77 @@ -129,10 +140,10 @@ static const char *colorname[] = { 78 * Default colors (colorname index) 79 * foreground, background, cursor, reverse cursor 80 */ 81 -unsigned int defaultfg = 258; 82 -unsigned int defaultbg = 259; 83 -unsigned int defaultcs = 256; 84 -static unsigned int defaultrcs = 257; 85 +unsigned int defaultfg = 12; 86 +unsigned int defaultbg = 8; 87 +unsigned int defaultcs = 14; 88 +static unsigned int defaultrcs = 15; 89 90 /* 91 * Default shape of cursor 92 @@ -201,6 +212,8 @@ static Shortcut shortcuts[] = { 93 { TERMMOD, XK_Y, selpaste, {.i = 0} }, 94 { ShiftMask, XK_Insert, selpaste, {.i = 0} }, 95 { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, 96 + { XK_ANY_MOD, XK_F6, swapcolors, {.i = 0} }, 97 + 98 }; 99 100 /* 101 diff --git a/st.h b/st.h 102 index fd3b0d8..4b4d5ab 100644 103 --- a/st.h 104 +++ b/st.h 105 @@ -120,6 +120,7 @@ extern wchar_t *worddelimiters; 106 extern int allowaltscreen; 107 extern int allowwindowops; 108 extern char *termname; 109 +extern int usealtcolors; 110 extern unsigned int tabspaces; 111 extern unsigned int defaultfg; 112 extern unsigned int defaultbg; 113 diff --git a/x.c b/x.c 114 index d73152b..c20077d 100644 115 --- a/x.c 116 +++ b/x.c 117 @@ -55,6 +55,7 @@ static void clipcopy(const Arg *); 118 static void clippaste(const Arg *); 119 static void numlock(const Arg *); 120 static void selpaste(const Arg *); 121 +static void swapcolors(const Arg *); 122 static void zoom(const Arg *); 123 static void zoomabs(const Arg *); 124 static void zoomreset(const Arg *); 125 @@ -254,6 +255,8 @@ static char *opt_title = NULL; 126 127 static uint buttons; /* bit field of pressed buttons */ 128 129 +int usealtcolors = 0; /* 1 to use alternate palette */ 130 + 131 void 132 clipcopy(const Arg *dummy) 133 { 134 @@ -292,6 +295,14 @@ numlock(const Arg *dummy) 135 win.mode ^= MODE_NUMLOCK; 136 } 137 138 +void 139 +swapcolors(const Arg *dummy) 140 +{ 141 + usealtcolors = !usealtcolors; 142 + xloadcols(); 143 + redraw(); 144 +} 145 + 146 void 147 zoom(const Arg *arg) 148 { 149 @@ -766,6 +777,11 @@ sixd_to_16bit(int x) 150 return x == 0 ? 0 : 0x3737 + 0x2828 * x; 151 } 152 153 +const char* getcolorname(int i) 154 +{ 155 + return (usealtcolors) ? altcolorname[i] : colorname[i]; 156 +} 157 + 158 int 159 xloadcolor(int i, const char *name, Color *ncolor) 160 { 161 @@ -784,7 +800,7 @@ xloadcolor(int i, const char *name, Color *ncolor) 162 return XftColorAllocValue(xw.dpy, xw.vis, 163 xw.cmap, &color, ncolor); 164 } else 165 - name = colorname[i]; 166 + name = getcolorname(i); 167 } 168 169 return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor); 170 @@ -807,8 +823,8 @@ xloadcols(void) 171 172 for (i = 0; i < dc.collen; i++) 173 if (!xloadcolor(i, NULL, &dc.col[i])) { 174 - if (colorname[i]) 175 - die("could not allocate color '%s'\n", colorname[i]); 176 + if (getcolorname(i)) 177 + die("could not allocate color '%s'\n", getcolorname(i)); 178 else 179 die("could not allocate color %d\n", i); 180 } 181 @@ -1203,13 +1219,15 @@ xinit(int cols, int rows) 182 cursor = XCreateFontCursor(xw.dpy, mouseshape); 183 XDefineCursor(xw.dpy, xw.win, cursor); 184 185 - if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) { 186 + if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousefg), &xmousefg) == 0) { 187 + 188 xmousefg.red = 0xffff; 189 xmousefg.green = 0xffff; 190 xmousefg.blue = 0xffff; 191 } 192 193 - if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) { 194 + if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousebg), &xmousebg) == 0) { 195 + 196 xmousebg.red = 0x0000; 197 xmousebg.green = 0x0000; 198 xmousebg.blue = 0x0000;