diff --git a/config.def.h b/config.def.h index 91ab8ca..5bbc088 100644 --- a/config.def.h +++ b/config.def.h @@ -5,7 +5,7 @@ * * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html */ -static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true"; +static char *font = "Iosevka Slab Light:size=12:antialias=true:autohint=true"; static int borderpx = 2; /* @@ -95,35 +95,61 @@ unsigned int tabspaces = 8; /* Terminal colors (16 first used in escape sequence) */ static const char *colorname[] = { - /* 8 normal colors */ - "black", - "red3", - "green3", - "yellow3", - "blue2", - "magenta3", - "cyan3", - "gray90", - - /* 8 bright colors */ - "gray50", - "red", - "green", - "yellow", - "#5c5cff", - "magenta", - "cyan", - "white", + /* windi dark */ + "#1f1f1f", /* 0: black */ + "#ef4444", /* 1: red */ + "#22c55e", /* 2: green */ + "#eab308", /* 3: yellow */ + "#3b82f6", /* 4: blue */ + "#d946ef", /* 5: magenta */ + "#06b6d4", /* 6: cyan */ + "#f2f2f2", /* 7: white */ + "#737373", /* 8: brblack */ + "#fecaca", /* 9: brred */ + "#bbf7d0", /* 10: brgreen */ + "#fef08a", /* 11: bryellow */ + "#bfdbfe", /* 12: brblue */ + "#f5d0fe", /* 13: brmagenta*/ + "#a5f3fc", /* 14: brcyan */ + "#fafafa", /* 15: brwhite */ [255] = 0, /* more colors can be added after 255 to use with DefaultXX */ - "#cccccc", - "#555555", - "gray90", /* default foreground colour */ - "black", /* default background colour */ + "white", + "black", + "#E7E7E7", /* default foreground colour */ + "#2C444D", }; +/* Terminal colors for alternate (light) palette */ +static const char *altcolorname[] = { + /* windi light */ + "#1b1b1b", /* 0: black */ + "#b91c1c", /* 1: red */ + "#15803d", /* 2: green */ + "#a16207", /* 3: yellow */ + "#1d4ed8", /* 4: blue */ + "#a21caf", /* 5: magenta*/ + "#0e7490", /* 6: cyan */ + "#e9ecef", /* 7: white */ + "#404040", /* 8: brblack */ + "#ef4444", /* 9: brred */ + "#22c55e", /* 10: brgreen */ + "#eab308", /* 11: bryellow */ + "#3b82f6", /* 12: brblue */ + "#d946ef", /* 13: brmagenta */ + "#06b6d4", /* 14: brcyan */ + "#f2f2f2", /* 15: brwhite */ + + [255] = 0, + + /* more colors can be added after 255 to use with DefaultXX */ + "#00638a", + "#f2f2f2", + "#454545", /* default foreground colour */ + "#f2f2f2", +}; /* * Default colors (colorname index) @@ -201,6 +227,7 @@ static Shortcut shortcuts[] = { { TERMMOD, XK_Y, selpaste, {.i = 0} }, { ShiftMask, XK_Insert, selpaste, {.i = 0} }, { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, + { XK_ANY_MOD, XK_F6, swapcolors, {.i = 0} }, }; /* diff --git a/st.h b/st.h index 519b9bd..c25b693 100644 --- a/st.h +++ b/st.h @@ -122,6 +122,7 @@ extern wchar_t *worddelimiters; extern int allowaltscreen; extern int allowwindowops; extern char *termname; +extern int usealtcolors; extern unsigned int tabspaces; extern unsigned int defaultfg; extern unsigned int defaultbg; diff --git a/x.c b/x.c index 8a16faa..4b569df 100644 --- a/x.c +++ b/x.c @@ -55,6 +55,7 @@ static void clipcopy(const Arg *); static void clippaste(const Arg *); static void numlock(const Arg *); static void selpaste(const Arg *); +static void swapcolors(const Arg *); static void zoom(const Arg *); static void zoomabs(const Arg *); static void zoomreset(const Arg *); @@ -254,6 +255,8 @@ static char *opt_title = NULL; static int oldbutton = 3; /* button event on startup: 3 = release */ +int usealtcolors = 0; /* 1 to use alternate palette */ + void clipcopy(const Arg *dummy) { @@ -292,6 +295,18 @@ numlock(const Arg *dummy) win.mode ^= MODE_NUMLOCK; } +void +swapcolors(const Arg *arg) +{ + int next = (arg->i == 'D') ? 0 : (arg->i == 'L') ? 1 : !usealtcolors; + + if (next != usealtcolors) { + usealtcolors = next; + xloadcols(); + redraw(); + } +} + void zoom(const Arg *arg) { @@ -750,6 +765,11 @@ sixd_to_16bit(int x) return x == 0 ? 0 : 0x3737 + 0x2828 * x; } +const char* getcolorname(int i) +{ + return (usealtcolors) ? altcolorname[i] : colorname[i]; +} + int xloadcolor(int i, const char *name, Color *ncolor) { @@ -768,7 +788,7 @@ xloadcolor(int i, const char *name, Color *ncolor) return XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, ncolor); } else - name = colorname[i]; + name = getcolorname(i); } return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor); @@ -791,8 +811,8 @@ xloadcols(void) for (i = 0; i < dc.collen; i++) if (!xloadcolor(i, NULL, &dc.col[i])) { - if (colorname[i]) - die("could not allocate color '%s'\n", colorname[i]); + if (getcolorname(i)) + die("could not allocate color '%s'\n", getcolorname(i)); else die("could not allocate color %d\n", i); } @@ -1184,13 +1204,13 @@ xinit(int cols, int rows) cursor = XCreateFontCursor(xw.dpy, mouseshape); XDefineCursor(xw.dpy, xw.win, cursor); - if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) { + if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousefg), &xmousefg) == 0) { xmousefg.red = 0xffff; xmousefg.green = 0xffff; xmousefg.blue = 0xffff; } - if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) { + if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousebg), &xmousebg) == 0) { xmousebg.red = 0x0000; xmousebg.green = 0x0000; xmousebg.blue = 0x0000; @@ -2008,6 +2028,15 @@ usage(void) " [stty_args ...]\n", argv0, argv0); } +void +sig_usr_handler(int num) +{ + Arg a = { .i = (num == 10) ? 'D' : 'L' }; + signal(num, sig_usr_handler); + swapcolors(&a); +} + + int main(int argc, char *argv[]) { @@ -2066,6 +2095,8 @@ run: if (!opt_title) opt_title = (opt_line || !opt_cmd) ? "st" : opt_cmd[0]; + signal(SIGUSR1, sig_usr_handler); + signal(SIGUSR2, sig_usr_handler); setlocale(LC_CTYPE, ""); XSetLocaleModifiers(""); cols = MAX(cols, 1);