logo

st

Unnamed repository; edit this file 'description' to name the repository.
commit: e61affc3317385cdee0e749da20a2fbb22acb0f3
parent: fa87c7afac1f0f1a866d7b7e1bb6f9d28ba97d37
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 23 Oct 2018 02:39:08 +0200

apply st-gruvbox-both-0.8.1.diff

Diffstat:

Mconfig.def.h68+++++++++++++++++++++++++++++++++++++++++++-------------------------
Mst.h1+
Mx.c28++++++++++++++++++++++------
3 files changed, 66 insertions(+), 31 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -84,31 +84,48 @@ 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", + /* gruvbox dark */ + "#282828", /* hard contrast: #1d2021 / soft contrast: #32302f / normal: #282828 */ + "#cc241d", + "#98971a", + "#d79921", + "#458588", + "#b16286", + "#689d6a", + "#a89984", + "#928374", + "#fb4934", + "#b8bb26", + "#fabd2f", + "#83a598", + "#d3869b", + "#8ec07c", + "#ebdbb2", [255] = 0, +}; - /* more colors can be added after 255 to use with DefaultXX */ - "#cccccc", - "#555555", +/* Terminal colors for alternate (light) palette */ +static const char *altcolorname[] = { + /* gruvbox light */ + "#fbf1c7", /* hard contrast: #f9f5d7 / soft contrast: #f2e5bc / normal: #fbf1c7 */ + "#cc241d", + "#98971a", + "#d79921", + "#458588", + "#b16286", + "#689d6a", + "#7c6f64", + "#928374", + "#9d0006", + "#79740e", + "#b57614", + "#076678", + "#8f3f71", + "#427b58", + "#3c3836", + + [255] = 0, }; @@ -116,10 +133,10 @@ static const char *colorname[] = { * Default colors (colorname index) * foreground, background, cursor, reverse cursor */ -unsigned int defaultfg = 7; +unsigned int defaultfg = 15; unsigned int defaultbg = 0; -static unsigned int defaultcs = 256; -static unsigned int defaultrcs = 257; +static unsigned int defaultcs = 15; +static unsigned int defaultrcs = 0; /* * Default shape of cursor @@ -178,6 +195,7 @@ static Shortcut shortcuts[] = { { TERMMOD, XK_Y, selpaste, {.i = 0} }, { TERMMOD, XK_Num_Lock, numlock, {.i = 0} }, { TERMMOD, XK_I, iso14755, {.i = 0} }, + { XK_ANY_MOD, XK_F6, swapcolors, {.i = 0} }, }; /* diff --git a/st.h b/st.h @@ -118,6 +118,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 *); @@ -240,6 +241,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) { @@ -279,6 +282,14 @@ numlock(const Arg *dummy) } void +swapcolors(const Arg *dummy) +{ + usealtcolors = !usealtcolors; + xloadcols(); + redraw(); +} + +void zoom(const Arg *arg) { Arg larg; @@ -700,6 +711,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) { @@ -718,7 +734,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); @@ -731,7 +747,7 @@ xloadcols(void) static int loaded; Color *cp; - dc.collen = MAX(LEN(colorname), 256); + dc.collen = MAX(LEN(colorname), LEN(altcolorname)); dc.col = xmalloc(dc.collen * sizeof(Color)); if (loaded) { @@ -741,8 +757,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); } @@ -1079,13 +1095,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;