sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

st-0.9.3-optionscheme.diff (17826B)


      1 diff -up st-0.9.3/config.def.h st-0.9.3-optionscheme/config.def.h
      2 --- st-0.9.3/config.def.h	2025-08-09 16:00:58.350298234 +0300
      3 +++ st-0.9.3-optionscheme/config.def.h	2025-12-23 18:36:25.103329012 +0300
      4 @@ -93,46 +93,211 @@ char *termname = "st-256color";
      5   */
      6  unsigned int tabspaces = 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/st.1 st-0.9.3-optionscheme/st.1
    253 --- st-0.9.3/st.1	2025-08-09 16:00:58.350298234 +0300
    254 +++ st-0.9.3-optionscheme/st.1	2025-12-23 21:02:54.482654368 +0300
    255 @@ -4,6 +4,8 @@ st \- simple terminal
    256  .SH SYNOPSIS
    257  .B st
    258  .RB [ \-aiv ]
    259 +.RB [ \-S
    260 +.IR scheme ]
    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 scheme ]
    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/st.c st-0.9.3-optionscheme/st.c
    297 --- st-0.9.3/st.c	2025-08-09 16:00:58.350298234 +0300
    298 +++ st-0.9.3-optionscheme/st.c	2025-12-23 15:20:01.557773970 +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/st.h st-0.9.3-optionscheme/st.h
    361 --- st-0.9.3/st.h	2025-08-09 16:00:58.350298234 +0300
    362 +++ st-0.9.3-optionscheme/st.h	2025-12-23 15:26:23.537781366 +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/x.c st-0.9.3-optionscheme/x.c
    388 --- st-0.9.3/x.c	2025-08-09 16:00:58.350298234 +0300
    389 +++ st-0.9.3-optionscheme/x.c	2025-12-23 21:04:02.912657886 +0300
    390 @@ -140,6 +140,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 @@ -151,6 +153,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 @@ -784,7 +787,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 @@ -801,14 +804,14 @@ 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 @@ -852,7 +855,7 @@ void
    435  xclear(int x1, int y1, int x2, int y2)
    436  {
    437  	XftDrawRect(xw.draw,
    438 -			&dc.col[IS_SET(MODE_REVERSE)? defaultfg : defaultbg],
    439 +			&dc.col[IS_SET(MODE_REVERSE)? seloptsch->defaultfg : seloptsch->defaultbg],
    440  			x1, y1, x2-x1, y2-y1);
    441  }
    442  
    443 @@ -1126,6 +1129,15 @@ xicdestroy(XIC xim, XPointer client, XPo
    444  	return 1;
    445  }
    446  
    447 +int
    448 +countoptsch()
    449 +{ 
    450 +	int i, optsch_limit = 256;
    451 +	for(i = 0; optionschemes[i] != NULL && i < optsch_limit; i++)
    452 +		;
    453 +	return i;
    454 +}
    455 +
    456  void
    457  xinit(int cols, int rows)
    458  {
    459 @@ -1148,6 +1160,15 @@ xinit(int cols, int rows)
    460  	xloadfonts(usedfont, 0);
    461  
    462  	/* colors */
    463 +	if (seloptschname) {
    464 +		int optschcount = countoptsch();
    465 +		for (int i = 0; optionschemes[i] && i < optschcount; i++) {
    466 +			if (strcmp(optionschemes[i]->name, seloptschname) == 0) {
    467 +				seloptsch = optionschemes[i];
    468 +				break;
    469 +			}
    470 +		}
    471 +	}
    472  	xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
    473  	xloadcols();
    474  
    475 @@ -1160,8 +1181,8 @@ xinit(int cols, int rows)
    476  		xw.t += DisplayHeight(xw.dpy, xw.scr) - win.h - 2;
    477  
    478  	/* Events */
    479 -	xw.attrs.background_pixel = dc.col[defaultbg].pixel;
    480 -	xw.attrs.border_pixel = dc.col[defaultbg].pixel;
    481 +	xw.attrs.background_pixel = dc.col[seloptsch->defaultbg].pixel;
    482 +	xw.attrs.border_pixel = dc.col[seloptsch->defaultbg].pixel;
    483  	xw.attrs.bit_gravity = NorthWestGravity;
    484  	xw.attrs.event_mask = FocusChangeMask | KeyPressMask | KeyReleaseMask
    485  		| ExposureMask | VisibilityChangeMask | StructureNotifyMask
    486 @@ -1184,7 +1205,7 @@ xinit(int cols, int rows)
    487  			&gcvalues);
    488  	xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
    489  			DefaultDepth(xw.dpy, xw.scr));
    490 -	XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
    491 +	XSetForeground(xw.dpy, dc.gc, dc.col[seloptsch->defaultbg].pixel);
    492  	XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
    493  
    494  	/* font spec buffer */
    495 @@ -1203,13 +1224,13 @@ xinit(int cols, int rows)
    496  	cursor = XCreateFontCursor(xw.dpy, mouseshape);
    497  	XDefineCursor(xw.dpy, xw.win, cursor);
    498  
    499 -	if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
    500 +	if (XParseColor(xw.dpy, xw.cmap, seloptsch->colors[mousefg], &xmousefg) == 0) {
    501  		xmousefg.red   = 0xffff;
    502  		xmousefg.green = 0xffff;
    503  		xmousefg.blue  = 0xffff;
    504  	}
    505  
    506 -	if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) {
    507 +	if (XParseColor(xw.dpy, xw.cmap, seloptsch->colors[mousebg], &xmousebg) == 0) {
    508  		xmousebg.red   = 0x0000;
    509  		xmousebg.green = 0x0000;
    510  		xmousebg.blue  = 0x0000;
    511 @@ -1420,8 +1441,8 @@ xdrawglyphfontspecs(const XftGlyphFontSp
    512  		fg = &dc.col[base.fg + 8];
    513  
    514  	if (IS_SET(MODE_REVERSE)) {
    515 -		if (fg == &dc.col[defaultfg]) {
    516 -			fg = &dc.col[defaultbg];
    517 +		if (fg == &dc.col[seloptsch->defaultfg]) {
    518 +			fg = &dc.col[seloptsch->defaultbg];
    519  		} else {
    520  			colfg.red = ~fg->color.red;
    521  			colfg.green = ~fg->color.green;
    522 @@ -1432,8 +1453,8 @@ xdrawglyphfontspecs(const XftGlyphFontSp
    523  			fg = &revfg;
    524  		}
    525  
    526 -		if (bg == &dc.col[defaultbg]) {
    527 -			bg = &dc.col[defaultfg];
    528 +		if (bg == &dc.col[seloptsch->defaultbg]) {
    529 +			bg = &dc.col[seloptsch->defaultfg];
    530  		} else {
    531  			colbg.red = ~bg->color.red;
    532  			colbg.green = ~bg->color.green;
    533 @@ -1539,21 +1560,21 @@ xdrawcursor(int cx, int cy, Glyph g, int
    534  
    535  	if (IS_SET(MODE_REVERSE)) {
    536  		g.mode |= ATTR_REVERSE;
    537 -		g.bg = defaultfg;
    538 +		g.bg = seloptsch->defaultfg;
    539  		if (selected(cx, cy)) {
    540 -			drawcol = dc.col[defaultcs];
    541 -			g.fg = defaultrcs;
    542 +			drawcol = dc.col[seloptsch->defaultcs];
    543 +			g.fg = seloptsch->defaultrcs;
    544  		} else {
    545 -			drawcol = dc.col[defaultrcs];
    546 -			g.fg = defaultcs;
    547 +			drawcol = dc.col[seloptsch->defaultrcs];
    548 +			g.fg = seloptsch->defaultcs;
    549  		}
    550  	} else {
    551  		if (selected(cx, cy)) {
    552 -			g.fg = defaultfg;
    553 -			g.bg = defaultrcs;
    554 +			g.fg = seloptsch->defaultfg;
    555 +			g.bg = seloptsch->defaultrcs;
    556  		} else {
    557 -			g.fg = defaultbg;
    558 -			g.bg = defaultcs;
    559 +			g.fg = seloptsch->defaultbg;
    560 +			g.bg = seloptsch->defaultcs;
    561  		}
    562  		drawcol = dc.col[g.bg];
    563  	}
    564 @@ -1692,7 +1713,7 @@ xfinishdraw(void)
    565  			win.h, 0, 0);
    566  	XSetForeground(xw.dpy, dc.gc,
    567  			dc.col[IS_SET(MODE_REVERSE)?
    568 -				defaultfg : defaultbg].pixel);
    569 +				seloptsch->defaultfg : seloptsch->defaultbg].pixel);
    570  }
    571  
    572  void
    573 @@ -2026,11 +2047,11 @@ run(void)
    574  void
    575  usage(void)
    576  {
    577 -	die("usage: %s [-aiv] [-c class] [-f font] [-g geometry]"
    578 +	die("usage: %s [-aiv] [-S colorscheme] [-c class] [-f font] [-g geometry]"
    579  	    " [-n name] [-o file]\n"
    580  	    "          [-T title] [-t title] [-w windowid]"
    581  	    " [[-e] command [args ...]]\n"
    582 -	    "       %s [-aiv] [-c class] [-f font] [-g geometry]"
    583 +	    "       %s [-aiv] [-S colorscheme] [-c class] [-f font] [-g geometry]"
    584  	    " [-n name] [-o file]\n"
    585  	    "          [-T title] [-t title] [-w windowid] -l line"
    586  	    " [stty_args ...]\n", argv0, argv0);
    587 @@ -2083,6 +2104,9 @@ main(int argc, char *argv[])
    588  	case 'v':
    589  		die("%s " VERSION "\n", argv0);
    590  		break;
    591 +	case 'S':
    592 +		seloptschname = EARGF(usage());
    593 +		break;
    594  	default:
    595  		usage();
    596  	} ARGEND;