old-st

[ARCHIVED] my build of st
git clone git://git.ckyln.com/~cem/old-st.git
Log | Files | Refs | README | LICENSE

commit 6501a5f65a1199e7849ff32f3398c783e96e4048
parent ec7c036b7bad9c4330a17678ded2ce3a5e270d72
Author: Cem Keylan <cem@ckyln.com>
Date:   Wed, 26 Jun 2019 13:39:09 +0300

Added Light Theme

Diffstat:
Mconfig.h | 71++++++++++++++++++++++++++++++++++++++++++++---------------------------
Mst.h | 1+
Mx.c | 28++++++++++++++++++++++------
3 files changed, 67 insertions(+), 33 deletions(-)

diff --git a/config.h b/config.h @@ -87,40 +87,55 @@ float alpha = 0.92; /* Terminal colors (16 first used in escape sequence) */ static const char *colorname[] = { - /* 8 normal colors */ - [0] = "#000000", /* black */ - [1] = "#ff5555", /* red */ - [2] = "#50fa7b", /* green */ - [3] = "#f1fa8c", /* yellow */ - [4] = "#bd93f9", /* blue */ - [5] = "#ff79c6", /* magenta */ - [6] = "#8be9fd", /* cyan */ - [7] = "#bbbbbb", /* white */ - - /* 8 bright colors */ - [8] = "#44475a", /* black */ - [9] = "#ff5555", /* red */ - [10] = "#50fa7b", /* green */ - [11] = "#f1fa8c", /* yellow */ - [12] = "#bd93f9", /* blue */ - [13] = "#ff79c6", /* magenta */ - [14] = "#8be9fd", /* cyan */ - [15] = "#ffffff", /* white */ - - /* special colors */ - [256] = "#282a36", /* background */ - [257] = "#f8f8f2", /* foreground */ + /* solarized dark */ + "#000000", /* 0: black */ + "#ff5555", /* 1: red */ + "#50fa7b", /* 2: green */ + "#f1fa8c", /* 3: yellow */ + "#bd93f9", /* 4: blue */ + "#ff79c6", /* 5: magenta */ + "#8be9fd", /* 6: cyan */ + "#bbbbbb", /* 7: white */ + "#44475a", /* 8: brblack */ + "#ff5555", /* 9: brred */ + "#50fa7b", /* 10: brgreen */ + "#f1fa8c", /* 11: bryellow */ + "#8be9fd", /* 12: brblue */ + "#ff79c6", /* 13: brmagenta*/ + "#8be9fd", /* 14: brcyan */ + "#ffffff", /* 15: brwhite */ }; +/* Terminal colors for alternate (light) palette */ +static const char *altcolorname[] = { + /* solarized light */ + "#eee8d5", /* 0: black */ + "#dc322f", /* 1: red */ + "#859900", /* 2: green */ + "#b58900", /* 3: yellow */ + "#268bd2", /* 4: blue */ + "#d33682", /* 5: magenta */ + "#2aa198", /* 6: cyan */ + "#073642", /* 7: white */ + "#fdf6e3", /* 8: brblack */ + "#cb4b16", /* 9: brred */ + "#93a1a1", /* 10: brgreen */ + "#839496", /* 11: bryellow */ + "#657b83", /* 12: brblue */ + "#6c71c4", /* 13: brmagenta*/ + "#586e75", /* 14: brcyan */ + "#002b36", /* 15: brwhite */ +}; /* * Default colors (colorname index) * foreground, background, cursor */ -unsigned int defaultfg = 257; -unsigned int defaultbg = 256; -static unsigned int defaultcs = 257; -static unsigned int defaultrcs = 257; + +unsigned int defaultfg = 12; +unsigned int defaultbg = 8; +static unsigned int defaultcs = 14; +static unsigned int defaultrcs = 15; /* * Default shape of cursor @@ -208,6 +223,8 @@ static Shortcut shortcuts[] = { { WINMOD, XK_C, externalpipe, { .v = copyurlcmd } }, { WINMOD, XK_O, externalpipe, { .v = openurlcmd } }, { TERMMOD, XK_O, externalpipe, { .v = copyoutput } }, + { XK_ANY_MOD, XK_F6, swapcolors, {.i = 0} }, + }; diff --git a/st.h b/st.h @@ -120,6 +120,7 @@ extern char *vtiden; extern char *worddelimiters; extern int allowaltscreen; 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 @@ -53,6 +53,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 *); @@ -242,6 +243,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) { @@ -281,6 +284,14 @@ numlock(const Arg *dummy) } void +swapcolors(const Arg *dummy) +{ + usealtcolors = !usealtcolors; + xloadcols(); + redraw(); +} + +void zoom(const Arg *arg) { Arg larg; @@ -704,6 +715,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) { @@ -722,7 +738,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); @@ -739,14 +755,14 @@ xloadcols(void) for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp) XftColorFree(xw.dpy, xw.vis, xw.cmap, cp); } else { - dc.collen = MAX(LEN(colorname), 256); + dc.collen = MAX(LEN(colorname), LEN(altcolorname)); dc.col = xmalloc(dc.collen * sizeof(Color)); } 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); } @@ -1099,13 +1115,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;