st-solarized-both-20170626-b331da5.diff (5955B)
1 diff --git a/config.def.h b/config.def.h 2 index 877afab..7305ec9 100644 3 --- a/config.def.h 4 +++ b/config.def.h 5 @@ -84,42 +84,54 @@ static unsigned int tabspaces = 8; 6 7 /* Terminal colors (16 first used in escape sequence) */ 8 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 + 54 +/* Terminal colors for alternate (light) palette */ 55 +const char *altcolorname[] = { 56 + /* solarized light */ 57 + "#eee8d5", /* 0: black */ 58 + "#dc322f", /* 1: red */ 59 + "#859900", /* 2: green */ 60 + "#b58900", /* 3: yellow */ 61 + "#268bd2", /* 4: blue */ 62 + "#d33682", /* 5: magenta */ 63 + "#2aa198", /* 6: cyan */ 64 + "#073642", /* 7: white */ 65 + "#fdf6e3", /* 8: brblack */ 66 + "#cb4b16", /* 9: brred */ 67 + "#93a1a1", /* 10: brgreen */ 68 + "#839496", /* 11: bryellow */ 69 + "#657b83", /* 12: brblue */ 70 + "#6c71c4", /* 13: brmagenta*/ 71 + "#586e75", /* 14: brcyan */ 72 + "#002b36", /* 15: brwhite */ 73 + }; 74 75 /* 76 * Default colors (colorname index) 77 * foreground, background, cursor, reverse cursor 78 */ 79 -unsigned int defaultfg = 7; 80 -unsigned int defaultbg = 0; 81 -unsigned int defaultcs = 256; 82 -unsigned int defaultrcs = 257; 83 +unsigned int defaultfg = 12; 84 +unsigned int defaultbg = 8; 85 +unsigned int defaultcs = 14; 86 +unsigned int defaultrcs = 15; 87 88 /* 89 * Default shape of cursor 90 @@ -178,6 +190,7 @@ Shortcut shortcuts[] = { 91 { TERMMOD, XK_Y, selpaste, {.i = 0} }, 92 { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, 93 { TERMMOD, XK_I, iso14755, {.i = 0} }, 94 + { XK_ANY_MOD, XK_F6, swapcolors, {.i = 0} }, 95 }; 96 97 /* 98 diff --git a/st.c b/st.c 99 index 8d4a9f2..fc7d9a6 100644 100 --- a/st.c 101 +++ b/st.c 102 @@ -129,6 +129,7 @@ typedef struct { 103 static void clipcopy(const Arg *); 104 static void clippaste(const Arg *); 105 static void numlock(const Arg *); 106 +static void swapcolors(const Arg *); 107 static void selpaste(const Arg *); 108 static void zoom(const Arg *); 109 static void zoomabs(const Arg *); 110 @@ -219,6 +220,8 @@ char *opt_name = NULL; 111 char *opt_title = NULL; 112 int oldbutton = 3; /* button event on startup: 3 = release */ 113 114 +int usealtcolors = 0; /* 1 to use alternate palette */ 115 + 116 static CSIEscape csiescseq; 117 static STREscape strescseq; 118 static int iofd = 1; 119 @@ -233,7 +236,7 @@ static Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000}; 120 static Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF}; 121 122 /* config.h array lengths */ 123 -size_t colornamelen = LEN(colorname); 124 +size_t colornamelen = MAX(LEN(colorname), LEN(altcolorname)); 125 size_t mshortcutslen = LEN(mshortcuts); 126 size_t shortcutslen = LEN(shortcuts); 127 size_t selmaskslen = LEN(selmasks); 128 @@ -2631,6 +2634,14 @@ numlock(const Arg *dummy) 129 term.numlock ^= 1; 130 } 131 132 +void 133 +swapcolors(const Arg *dummy) 134 +{ 135 + usealtcolors = !usealtcolors; 136 + xloadcols(); 137 + redraw(); 138 +} 139 + 140 char* 141 kmap(KeySym k, uint state) 142 { 143 diff --git a/st.h b/st.h 144 index 44d4938..c464dd3 100644 145 --- a/st.h 146 +++ b/st.h 147 @@ -250,7 +250,9 @@ extern unsigned int cursorthickness; 148 extern unsigned int blinktimeout; 149 extern char termname[]; 150 extern const char *colorname[]; 151 +extern const char *altcolorname[]; 152 extern size_t colornamelen; 153 +extern int usealtcolors; 154 extern unsigned int defaultfg; 155 extern unsigned int defaultbg; 156 extern unsigned int defaultcs; 157 diff --git a/x.c b/x.c 158 index fbfd350..886918b 100644 159 --- a/x.c 160 +++ b/x.c 161 @@ -138,6 +138,7 @@ static void (*handler[LASTEvent])(XEvent *) = { 162 /* Globals */ 163 static DC dc; 164 static XWindow xw; 165 + 166 static XSelection xsel; 167 168 /* Font Ring Cache */ 169 @@ -573,6 +574,11 @@ sixd_to_16bit(int x) 170 return x == 0 ? 0 : 0x3737 + 0x2828 * x; 171 } 172 173 +const char* getcolorname(int i) 174 +{ 175 + return (usealtcolors) ? altcolorname[i] : colorname[i]; 176 +} 177 + 178 int 179 xloadcolor(int i, const char *name, Color *ncolor) 180 { 181 @@ -591,7 +597,7 @@ xloadcolor(int i, const char *name, Color *ncolor) 182 return XftColorAllocValue(xw.dpy, xw.vis, 183 xw.cmap, &color, ncolor); 184 } else 185 - name = colorname[i]; 186 + name = getcolorname(i); 187 } 188 189 return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor); 190 @@ -614,8 +620,8 @@ xloadcols(void) 191 192 for (i = 0; i < dc.collen; i++) 193 if (!xloadcolor(i, NULL, &dc.col[i])) { 194 - if (colorname[i]) 195 - die("Could not allocate color '%s'\n", colorname[i]); 196 + if (getcolorname(i)) 197 + die("Could not allocate color '%s'\n", getcolorname(i)); 198 else 199 die("Could not allocate color %d\n", i); 200 } 201 @@ -950,13 +956,13 @@ xinit(void) 202 cursor = XCreateFontCursor(xw.dpy, mouseshape); 203 XDefineCursor(xw.dpy, xw.win, cursor); 204 205 - if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) { 206 + if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousefg), &xmousefg) == 0) { 207 xmousefg.red = 0xffff; 208 xmousefg.green = 0xffff; 209 xmousefg.blue = 0xffff; 210 } 211 212 - if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) { 213 + if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousebg), &xmousebg) == 0) { 214 xmousebg.red = 0x0000; 215 xmousebg.green = 0x0000; 216 xmousebg.blue = 0x0000;