st-0.9.3-optionscheme-alpha.diff (18957B)
1 diff -up st-0.9.3-alpha/config.def.h st-0.9.3-optionscheme-alpha/config.def.h 2 --- st-0.9.3-alpha/config.def.h 2025-12-23 16:14:47.967839255 +0300 3 +++ st-0.9.3-optionscheme-alpha/config.def.h 2025-12-23 18:36:25.099995678 +0300 4 @@ -96,46 +96,211 @@ unsigned int tabspaces = 8; 5 /* bg opacity */ 6 float alpha = 0.8; 7 8 -/* Terminal colors (16 first used in escape sequence) */ 9 -static const char *colorname[] = { 10 - /* 8 normal colors */ 11 - "black", 12 - "red3", 13 - "green3", 14 - "yellow3", 15 - "blue2", 16 - "magenta3", 17 - "cyan3", 18 - "gray90", 19 - 20 - /* 8 bright colors */ 21 - "gray50", 22 - "red", 23 - "green", 24 - "yellow", 25 - "#5c5cff", 26 - "magenta", 27 - "cyan", 28 - "white", 29 - 30 - [255] = 0, 31 - 32 - /* more colors can be added after 255 to use with DefaultXX */ 33 - "#cccccc", 34 - "#555555", 35 - "gray90", /* default foreground colour */ 36 - "black", /* default background colour */ 37 +/* loaded if couldn't find scheme, has to be present */ 38 +static const OptionScheme optionscheme_default = { 39 + .name = "default", 40 + .colors = { 41 + /* 8 normal colors */ 42 + "black", /* 0 */ 43 + "red3", /* 1 */ 44 + "green3", /* 2 */ 45 + "yellow3", /* 3 */ 46 + "blue2", /* 4 */ 47 + "magenta3", /* 5 */ 48 + "cyan3", /* 6 */ 49 + "gray90", /* 7 */ 50 + 51 + /* 8 bright colors */ 52 + "gray50", /* 8 */ 53 + "red", /* 9 */ 54 + "green", /* 10 */ 55 + "yellow", /* 11 */ 56 + "#5c5cff", /* 12 */ 57 + "magenta", /* 13 */ 58 + "cyan", /* 14 */ 59 + "white", /* 15 */ 60 + 61 + [255] = 0, 62 + 63 + /* DefaultXX colors */ 64 + "#cccccc", /* 256 */ 65 + "#555555", /* 257 */ 66 + "gray90", /* 258 default foreground */ 67 + "black", /* 259 default background */ 68 + }, 69 + .defaultfg = 258, 70 + .defaultbg = 259, 71 + .defaultcs = 258, 72 + .defaultrcs = 259, 73 }; 74 75 +static const OptionScheme optionscheme_dracula = { 76 + .name = "dracula", 77 + .colors = { 78 + /* 8 normal */ 79 + [0] = "#282a36", [1] = "#ff5555", [2] = "#50fa7b", [3] = "#f1fa8c", 80 + [4] = "#bd93f9", [5] = "#ff79c6", [6] = "#8be9fd", [7] = "#bbbbbb", 81 + /* 8 bright */ 82 + [8] = "#6272a4", [9] = "#ff6e6e", [10] = "#69ff94", [11] = "#ffffa5", 83 + [12] = "#d6acff", [13] = "#ff92df", [14] = "#a4ffff", [15] = "#ffffff", 84 + 85 + [255] = 0, 86 + 87 + /* DefaultXX */ 88 + [256] = "#f8f8f2", /* cursor */ 89 + [257] = "#44475a", /* reverse cursor */ 90 + [258] = "#f8f8f2", /* fg */ 91 + [259] = "#282a36" /* bg */ 92 + }, 93 + .defaultfg = 258, 94 + .defaultbg = 259, 95 + .defaultcs = 256, 96 + .defaultrcs = 257 97 +}; 98 + 99 +static const OptionScheme optionscheme_solarized = { 100 + .name = "solarized", 101 + .colors = { 102 + /* 8 normal colors */ 103 + [0] = "#002b36", [1] = "#dc322f", [2] = "#859900", [3] = "#b58900", 104 + [4] = "#268bd2", [5] = "#6c71c4", [6] = "#2aa198", [7] = "#93a1a1", 105 + /* 8 bright colors */ 106 + [8] = "#657b83", [9] = "#dc322f", [10] = "#859900", [11] = "#b58900", 107 + [12] = "#268bd2", [13] = "#6c71c4", [14] = "#2aa198", [15] = "#fdf6e3", 108 + 109 + [255] = 0, 110 + 111 + /* DefaultXX */ 112 + [256] = "#839496", [257] = "#002b36", [258] = "#839496", [259] = "#002b36" 113 + }, 114 + .defaultfg = 258, 115 + .defaultbg = 259, 116 + .defaultcs = 256, 117 + .defaultrcs = 257 118 +}; 119 + 120 +static const OptionScheme optionscheme_nord = { 121 + .name = "nord", 122 + .colors = { 123 + /* 8 normal */ 124 + [0] = "#3b4252", [1] = "#bf616a", [2] = "#a3be8c", [3] = "#ebcb8b", 125 + [4] = "#81a1c1", [5] = "#b48ead", [6] = "#88c0d0", [7] = "#e5e9f0", 126 + /* 8 bright */ 127 + [8] = "#4c566a", [9] = "#bf616a", [10] = "#a3be8c", [11] = "#ebcb8b", 128 + [12] = "#81a1c1", [13] = "#b48ead", [14] = "#8fbcbb", [15] = "#eceff4", 129 + 130 + [255] = 0, 131 + 132 + /* DefaultXX */ 133 + [256] = "#d8dee9", [257] = "#2e3440", [258] = "#d8dee9", [259] = "#2e3440" 134 + }, 135 + .defaultfg = 258, 136 + .defaultbg = 259, 137 + .defaultcs = 256, 138 + .defaultrcs = 257 139 +}; 140 + 141 +static const OptionScheme optionscheme_gruvbox = { 142 + .name = "gruvbox", 143 + .colors = { 144 + /* 8 normal */ 145 + [0] = "#282828", [1] = "#cc241d", [2] = "#98971a", [3] = "#d79921", 146 + [4] = "#458588", [5] = "#b16286", [6] = "#689d6a", [7] = "#a89984", 147 + /* 8 bright */ 148 + [8] = "#928374", [9] = "#fb4934", [10] = "#b8bb26", [11] = "#fabd2f", 149 + [12] = "#83a598", [13] = "#d3869b", [14] = "#8ec07c", [15] = "#ebdbb2", 150 + 151 + [255] = 0, 152 + 153 + /* DefaultXX */ 154 + [256] = "#ebdbb2", [257] = "#282828", [258] = "#ebdbb2", [259] = "#282828" 155 + }, 156 + .defaultfg = 258, 157 + .defaultbg = 259, 158 + .defaultcs = 256, 159 + .defaultrcs = 257 160 +}; 161 + 162 +static const OptionScheme optionscheme_plan9 = { 163 + .name = "plan9", 164 + .colors = { 165 + /* 8 normal colors */ 166 + [0] = "#000000", [1] = "#9c0000", [2] = "#008000", [3] = "#999900", 167 + [4] = "#00009c", [5] = "#990099", [6] = "#009999", [7] = "#7f7f7f", 168 + /* 8 bright colors */ 169 + [8] = "#c0c0c0", [9] = "#ff0000", [10] = "#00ff00", [11] = "#ffff00", 170 + [12] = "#5c5cff", [13] = "#ff00ff", [14] = "#00ffff", [15] = "#ffffff", 171 + 172 + [255] = 0, 173 + 174 + /* DefaultXX colors */ 175 + [256] = "#000000", [257] = "#9ecfff", [258] = "#000000", [259] = "#ffffea" 176 + }, 177 + .defaultfg = 258, 178 + .defaultbg = 259, 179 + .defaultcs = 256, 180 + .defaultrcs = 257 181 +}; 182 + 183 +static const OptionScheme optionscheme_cyberpunk = { 184 + .name = "cyberpunk", 185 + .colors = { 186 + /* 8 normal */ 187 + [0] = "#0d0221", [1] = "#ff004d", [2] = "#00ff9f", [3] = "#fffa72", 188 + [4] = "#00caff", [5] = "#ff00ff", [6] = "#0affef", [7] = "#a0a0a0", 189 + /* 8 bright */ 190 + [8] = "#3a0f5c", [9] = "#ff4d79", [10] = "#4dffb8", [11] = "#fffaa0", 191 + [12] = "#4dd2ff", [13] = "#ff4dff", [14] = "#4df9ff", [15] = "#ffffff", 192 + 193 + [255] = 0, 194 + 195 + /* DefaultXX */ 196 + [256] = "#00ffcc", [257] = "#0d0221", [258] = "#00ffcc", [259] = "#0d0221" 197 + }, 198 + .defaultfg = 258, 199 + .defaultbg = 259, 200 + .defaultcs = 256, 201 + .defaultrcs = 257 202 +}; 203 + 204 +static const OptionScheme optionscheme_light = { 205 + .name = "light", 206 + .colors = { 207 + /* 8 normal colors */ 208 + [0] = "#000000", [1] = "#d70000", [2] = "#008700", [3] = "#af8700", 209 + [4] = "#005faf", [5] = "#8700af", [6] = "#00afaf", [7] = "#d0d0d0", 210 + /* 8 bright colors */ 211 + [8] = "#808080", [9] = "#ff0000", [10] = "#00ff00", [11] = "#ffff00", 212 + [12] = "#5c5cff", [13] = "#ff00ff", [14] = "#00ffff", [15] = "#ffffff", 213 + 214 + [255] = 0, 215 + 216 + /* DefaultXX colors */ 217 + [256] = "#000000", [257] = "#4a90e2", [258] = "#000000", [259] = "#eeeeee" 218 + }, 219 + .defaultfg = 258, 220 + .defaultbg = 259, 221 + .defaultcs = 256, 222 + .defaultrcs = 257 223 +}; 224 225 /* 226 - * Default colors (colorname index) 227 - * foreground, background, cursor, reverse cursor 228 - */ 229 -unsigned int defaultfg = 258; 230 -unsigned int defaultbg = 259; 231 -unsigned int defaultcs = 256; 232 -static unsigned int defaultrcs = 257; 233 + * you can move the schemes to a different header and do #include "optionschemes.h" 234 + * or you can move each scheme to its own file 235 + * and do #include optionscheme_light.h, #include optionscheme_plan9.h, ... 236 + * */ 237 + 238 +static const OptionScheme *optionschemes[] = { 239 + &optionscheme_default, 240 + &optionscheme_light, 241 + &optionscheme_plan9, 242 + &optionscheme_dracula, 243 + &optionscheme_solarized, 244 + &optionscheme_nord, 245 + &optionscheme_gruvbox, 246 + &optionscheme_cyberpunk, 247 + NULL /* has to be NULL terminated */ 248 +}; 249 250 /* 251 * Default shape of cursor 252 diff -up st-0.9.3-alpha/st.1 st-0.9.3-optionscheme-alpha/st.1 253 --- st-0.9.3-alpha/st.1 2025-12-23 16:14:37.637839051 +0300 254 +++ st-0.9.3-optionscheme-alpha/st.1 2025-12-23 21:00:52.432648093 +0300 255 @@ -4,6 +4,8 @@ st \- simple terminal 256 .SH SYNOPSIS 257 .B st 258 .RB [ \-aiv ] 259 +.RB [ \-S 260 +.IR colorscheme ] 261 .RB [ \-c 262 .IR class ] 263 .RB [ \-f 264 @@ -28,6 +30,8 @@ st \- simple terminal 265 .PP 266 .B st 267 .RB [ \-aiv ] 268 +.RB [ \-S 269 +.IR colorscheme ] 270 .RB [ \-c 271 .IR class ] 272 .RB [ \-f 273 @@ -55,6 +59,22 @@ is a simple terminal emulator. 274 .B \-a 275 disable alternate screens in terminal 276 .TP 277 +.BI \-S " scheme" 278 +Sets the terminal color scheme. 279 +The following schemes are supported: 280 +.BR default , 281 +.BR light , 282 +.BR plan9 , 283 +.BR dracula , 284 +.BR solarized , 285 +.BR nord , 286 +.BR gruvbox , 287 +and 288 +.BR cyberpunk . 289 +If no scheme is specified, or if an unknown scheme is given, 290 +.B default 291 +is used. 292 +.TP 293 .BI \-c " class" 294 defines the window class (default $TERM). 295 .TP 296 diff -up st-0.9.3-alpha/st.c st-0.9.3-optionscheme-alpha/st.c 297 --- st-0.9.3-alpha/st.c 2025-12-23 16:14:37.637839051 +0300 298 +++ st-0.9.3-optionscheme-alpha/st.c 2025-12-23 16:41:21.057870817 +0300 299 @@ -1014,8 +1014,8 @@ treset(void) 300 301 term.c = (TCursor){{ 302 .mode = ATTR_NULL, 303 - .fg = defaultfg, 304 - .bg = defaultbg 305 + .fg = seloptsch->defaultfg, 306 + .bg = seloptsch->defaultbg 307 }, .x = 0, .y = 0, .state = CURSOR_DEFAULT}; 308 309 memset(term.tabs, 0, term.col * sizeof(*term.tabs)); 310 @@ -1038,7 +1038,7 @@ treset(void) 311 void 312 tnew(int col, int row) 313 { 314 - term = (Term){ .c = { .attr = { .fg = defaultfg, .bg = defaultbg } } }; 315 + term = (Term){ .c = { .attr = { .fg = seloptsch->defaultfg, .bg = seloptsch->defaultbg } } }; 316 tresize(col, row); 317 treset(); 318 } 319 @@ -1366,8 +1366,8 @@ tsetattr(const int *attr, int l) 320 ATTR_REVERSE | 321 ATTR_INVISIBLE | 322 ATTR_STRUCK ); 323 - term.c.attr.fg = defaultfg; 324 - term.c.attr.bg = defaultbg; 325 + term.c.attr.fg = seloptsch->defaultfg; 326 + term.c.attr.bg = seloptsch->defaultbg; 327 break; 328 case 1: 329 term.c.attr.mode |= ATTR_BOLD; 330 @@ -1421,14 +1421,14 @@ tsetattr(const int *attr, int l) 331 term.c.attr.fg = idx; 332 break; 333 case 39: /* set foreground color to default */ 334 - term.c.attr.fg = defaultfg; 335 + term.c.attr.fg = seloptsch->defaultfg; 336 break; 337 case 48: 338 if ((idx = tdefcolor(attr, &i, l)) >= 0) 339 term.c.attr.bg = idx; 340 break; 341 case 49: /* set background color to default */ 342 - term.c.attr.bg = defaultbg; 343 + term.c.attr.bg = seloptsch->defaultbg; 344 break; 345 case 58: 346 /* This starts a sequence to change the color of 347 @@ -1887,9 +1887,9 @@ strhandle(void) 348 char *p = NULL, *dec; 349 int j, narg, par; 350 const struct { int idx; char *str; } osc_table[] = { 351 - { defaultfg, "foreground" }, 352 - { defaultbg, "background" }, 353 - { defaultcs, "cursor" } 354 + { seloptsch->defaultfg, "foreground" }, 355 + { seloptsch->defaultbg, "background" }, 356 + { seloptsch->defaultcs, "cursor" } 357 }; 358 359 term.esc &= ~(ESC_STR_END|ESC_STR); 360 diff -up st-0.9.3-alpha/st.h st-0.9.3-optionscheme-alpha/st.h 361 --- st-0.9.3-alpha/st.h 2025-12-23 16:14:37.637839051 +0300 362 +++ st-0.9.3-optionscheme-alpha/st.h 2025-12-23 16:38:18.397867197 +0300 363 @@ -59,6 +59,15 @@ typedef unsigned short ushort; 364 365 typedef uint_least32_t Rune; 366 367 +typedef struct { 368 + const char *name; 369 + const char *colors[260]; 370 + unsigned int defaultfg; 371 + unsigned int defaultbg; 372 + unsigned int defaultcs; 373 + unsigned int defaultrcs; 374 +} OptionScheme; 375 + 376 #define Glyph Glyph_ 377 typedef struct { 378 Rune u; /* character code */ 379 @@ -121,6 +130,4 @@ extern int allowaltscreen; 380 extern int allowwindowops; 381 extern char *termname; 382 extern unsigned int tabspaces; 383 -extern unsigned int defaultfg; 384 -extern unsigned int defaultbg; 385 -extern unsigned int defaultcs; 386 +extern const OptionScheme *seloptsch; 387 diff -up st-0.9.3-alpha/x.c st-0.9.3-optionscheme-alpha/x.c 388 --- st-0.9.3-alpha/x.c 2025-12-23 16:14:47.967839255 +0300 389 +++ st-0.9.3-optionscheme-alpha/x.c 2025-12-23 16:41:13.161203992 +0300 390 @@ -141,6 +141,8 @@ typedef struct { 391 GC gc; 392 } DC; 393 394 +const OptionScheme *seloptsch = &optionscheme_default; 395 +static const char *seloptschname = NULL; 396 static inline ushort sixd_to_16bit(int); 397 static int xmakeglyphfontspecs(XftGlyphFontSpec *, const Glyph *, int, int, int); 398 static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int); 399 @@ -152,6 +154,7 @@ static void ximinstantiate(Display *, XP 400 static void ximdestroy(XIM, XPointer, XPointer); 401 static int xicdestroy(XIC, XPointer, XPointer); 402 static void xinit(int, int); 403 +static int countoptsch(); 404 static void cresize(int, int); 405 static void xresize(int, int); 406 static void xhints(void); 407 @@ -785,7 +788,7 @@ xloadcolor(int i, const char *name, Colo 408 return XftColorAllocValue(xw.dpy, xw.vis, 409 xw.cmap, &color, ncolor); 410 } else 411 - name = colorname[i]; 412 + name = seloptsch->colors[i]; 413 } 414 415 return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor); 416 @@ -802,21 +805,21 @@ xloadcols(void) 417 for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp) 418 XftColorFree(xw.dpy, xw.vis, xw.cmap, cp); 419 } else { 420 - dc.collen = MAX(LEN(colorname), 256); 421 + dc.collen = MAX(LEN(seloptsch->colors), 256); 422 dc.col = xmalloc(dc.collen * sizeof(Color)); 423 } 424 425 for (i = 0; i < dc.collen; i++) 426 if (!xloadcolor(i, NULL, &dc.col[i])) { 427 - if (colorname[i]) 428 - die("could not allocate color '%s'\n", colorname[i]); 429 + if (seloptsch->colors[i]) 430 + die("could not allocate color '%s'\n", seloptsch->colors[i]); 431 else 432 die("could not allocate color %d\n", i); 433 } 434 435 - dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); 436 - dc.col[defaultbg].pixel &= 0x00FFFFFF; 437 - dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; 438 + dc.col[seloptsch->defaultbg].color.alpha = (unsigned short)(0xffff * alpha); 439 + dc.col[seloptsch->defaultbg].pixel &= 0x00FFFFFF; 440 + dc.col[seloptsch->defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; 441 loaded = 1; 442 } 443 444 @@ -847,10 +850,10 @@ xsetcolorname(int x, const char *name) 445 XftColorFree(xw.dpy, xw.vis, xw.cmap, &dc.col[x]); 446 dc.col[x] = ncolor; 447 448 - if (x == defaultbg) { 449 - dc.col[defaultbg].color.alpha = (unsigned short)(0xffff * alpha); 450 - dc.col[defaultbg].pixel &= 0x00FFFFFF; 451 - dc.col[defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; 452 + if (x == seloptsch->defaultbg) { 453 + dc.col[seloptsch->defaultbg].color.alpha = (unsigned short)(0xffff * alpha); 454 + dc.col[seloptsch->defaultbg].pixel &= 0x00FFFFFF; 455 + dc.col[seloptsch->defaultbg].pixel |= (unsigned char)(0xff * alpha) << 24; 456 } 457 458 return 0; 459 @@ -863,7 +866,7 @@ void 460 xclear(int x1, int y1, int x2, int y2) 461 { 462 XftDrawRect(xw.draw, 463 - &dc.col[IS_SET(MODE_REVERSE)? defaultfg : defaultbg], 464 + &dc.col[IS_SET(MODE_REVERSE)? seloptsch->defaultfg : seloptsch->defaultbg], 465 x1, y1, x2-x1, y2-y1); 466 } 467 468 @@ -1137,6 +1140,15 @@ xicdestroy(XIC xim, XPointer client, XPo 469 return 1; 470 } 471 472 +int 473 +countoptsch() 474 +{ 475 + int i, optsch_limit = 256; 476 + for(i = 0; optionschemes[i] != NULL && i < optsch_limit; i++) 477 + ; 478 + return i; 479 +} 480 + 481 void 482 xinit(int cols, int rows) 483 { 484 @@ -1173,6 +1185,15 @@ xinit(int cols, int rows) 485 xloadfonts(usedfont, 0); 486 487 /* colors */ 488 + if (seloptschname) { 489 + int optschcount = countoptsch(); 490 + for (int i = 0; optionschemes[i] && i < optschcount; i++) { 491 + if (strcmp(optionschemes[i]->name, seloptschname) == 0) { 492 + seloptsch = optionschemes[i]; 493 + break; 494 + } 495 + } 496 + } 497 xw.cmap = XCreateColormap(xw.dpy, parent, xw.vis, None); 498 xloadcols(); 499 500 @@ -1185,8 +1206,8 @@ xinit(int cols, int rows) 501 xw.t += DisplayHeight(xw.dpy, xw.scr) - win.h - 2; 502 503 /* Events */ 504 - xw.attrs.background_pixel = dc.col[defaultbg].pixel; 505 - xw.attrs.border_pixel = dc.col[defaultbg].pixel; 506 + xw.attrs.background_pixel = dc.col[seloptsch->defaultbg].pixel; 507 + xw.attrs.border_pixel = dc.col[seloptsch->defaultbg].pixel; 508 xw.attrs.bit_gravity = NorthWestGravity; 509 xw.attrs.event_mask = FocusChangeMask | KeyPressMask | KeyReleaseMask 510 | ExposureMask | VisibilityChangeMask | StructureNotifyMask 511 @@ -1206,7 +1227,7 @@ xinit(int cols, int rows) 512 &gcvalues); 513 xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h, 514 xw.depth); 515 - XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); 516 + XSetForeground(xw.dpy, dc.gc, dc.col[seloptsch->defaultbg].pixel); 517 XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h); 518 519 /* font spec buffer */ 520 @@ -1225,13 +1246,13 @@ xinit(int cols, int rows) 521 cursor = XCreateFontCursor(xw.dpy, mouseshape); 522 XDefineCursor(xw.dpy, xw.win, cursor); 523 524 - if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) { 525 + if (XParseColor(xw.dpy, xw.cmap, seloptsch->colors[mousefg], &xmousefg) == 0) { 526 xmousefg.red = 0xffff; 527 xmousefg.green = 0xffff; 528 xmousefg.blue = 0xffff; 529 } 530 531 - if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) { 532 + if (XParseColor(xw.dpy, xw.cmap, seloptsch->colors[mousebg], &xmousebg) == 0) { 533 xmousebg.red = 0x0000; 534 xmousebg.green = 0x0000; 535 xmousebg.blue = 0x0000; 536 @@ -1442,8 +1463,8 @@ xdrawglyphfontspecs(const XftGlyphFontSp 537 fg = &dc.col[base.fg + 8]; 538 539 if (IS_SET(MODE_REVERSE)) { 540 - if (fg == &dc.col[defaultfg]) { 541 - fg = &dc.col[defaultbg]; 542 + if (fg == &dc.col[seloptsch->defaultfg]) { 543 + fg = &dc.col[seloptsch->defaultbg]; 544 } else { 545 colfg.red = ~fg->color.red; 546 colfg.green = ~fg->color.green; 547 @@ -1454,8 +1475,8 @@ xdrawglyphfontspecs(const XftGlyphFontSp 548 fg = &revfg; 549 } 550 551 - if (bg == &dc.col[defaultbg]) { 552 - bg = &dc.col[defaultfg]; 553 + if (bg == &dc.col[seloptsch->defaultbg]) { 554 + bg = &dc.col[seloptsch->defaultfg]; 555 } else { 556 colbg.red = ~bg->color.red; 557 colbg.green = ~bg->color.green; 558 @@ -1561,21 +1582,21 @@ xdrawcursor(int cx, int cy, Glyph g, int 559 560 if (IS_SET(MODE_REVERSE)) { 561 g.mode |= ATTR_REVERSE; 562 - g.bg = defaultfg; 563 + g.bg = seloptsch->defaultfg; 564 if (selected(cx, cy)) { 565 - drawcol = dc.col[defaultcs]; 566 - g.fg = defaultrcs; 567 + drawcol = dc.col[seloptsch->defaultcs]; 568 + g.fg = seloptsch->defaultrcs; 569 } else { 570 - drawcol = dc.col[defaultrcs]; 571 - g.fg = defaultcs; 572 + drawcol = dc.col[seloptsch->defaultrcs]; 573 + g.fg = seloptsch->defaultcs; 574 } 575 } else { 576 if (selected(cx, cy)) { 577 - g.fg = defaultfg; 578 - g.bg = defaultrcs; 579 + g.fg = seloptsch->defaultfg; 580 + g.bg = seloptsch->defaultrcs; 581 } else { 582 - g.fg = defaultbg; 583 - g.bg = defaultcs; 584 + g.fg = seloptsch->defaultbg; 585 + g.bg = seloptsch->defaultcs; 586 } 587 drawcol = dc.col[g.bg]; 588 } 589 @@ -1714,7 +1735,7 @@ xfinishdraw(void) 590 win.h, 0, 0); 591 XSetForeground(xw.dpy, dc.gc, 592 dc.col[IS_SET(MODE_REVERSE)? 593 - defaultfg : defaultbg].pixel); 594 + seloptsch->defaultfg : seloptsch->defaultbg].pixel); 595 } 596 597 void 598 @@ -2048,11 +2069,11 @@ run(void) 599 void 600 usage(void) 601 { 602 - die("usage: %s [-aiv] [-c class] [-f font] [-g geometry]" 603 + die("usage: %s [-aiv] [-S colorscheme] [-c class] [-f font] [-g geometry]" 604 " [-n name] [-o file]\n" 605 " [-T title] [-t title] [-w windowid]" 606 " [[-e] command [args ...]]\n" 607 - " %s [-aiv] [-c class] [-f font] [-g geometry]" 608 + " %s [-aiv] [-S colorscheme] [-c class] [-f font] [-g geometry]" 609 " [-n name] [-o file]\n" 610 " [-T title] [-t title] [-w windowid] -l line" 611 " [stty_args ...]\n", argv0, argv0); 612 @@ -2109,6 +2130,9 @@ main(int argc, char *argv[]) 613 case 'v': 614 die("%s " VERSION "\n", argv0); 615 break; 616 + case 'S': 617 + seloptschname = EARGF(usage()); 618 + break; 619 default: 620 usage(); 621 } ARGEND;