Solarized support + switch with F6
This commit is contained in:
parent
e0a07a9392
commit
efde1e896e
71
config.def.h
71
config.def.h
@ -84,42 +84,54 @@ static unsigned int tabspaces = 8;
|
|||||||
|
|
||||||
/* Terminal colors (16 first used in escape sequence) */
|
/* Terminal colors (16 first used in escape sequence) */
|
||||||
static const char *colorname[] = {
|
static const char *colorname[] = {
|
||||||
/* 8 normal colors */
|
/* solarized dark */
|
||||||
"black",
|
"#073642", /* 0: black */
|
||||||
"red3",
|
"#dc322f", /* 1: red */
|
||||||
"green3",
|
"#859900", /* 2: green */
|
||||||
"yellow3",
|
"#b58900", /* 3: yellow */
|
||||||
"blue2",
|
"#268bd2", /* 4: blue */
|
||||||
"magenta3",
|
"#d33682", /* 5: magenta */
|
||||||
"cyan3",
|
"#2aa198", /* 6: cyan */
|
||||||
"gray90",
|
"#eee8d5", /* 7: white */
|
||||||
|
"#002b36", /* 8: brblack */
|
||||||
/* 8 bright colors */
|
"#cb4b16", /* 9: brred */
|
||||||
"gray50",
|
"#586e75", /* 10: brgreen */
|
||||||
"red",
|
"#657b83", /* 11: bryellow */
|
||||||
"green",
|
"#839496", /* 12: brblue */
|
||||||
"yellow",
|
"#6c71c4", /* 13: brmagenta*/
|
||||||
"#5c5cff",
|
"#93a1a1", /* 14: brcyan */
|
||||||
"magenta",
|
"#fdf6e3", /* 15: brwhite */
|
||||||
"cyan",
|
|
||||||
"white",
|
|
||||||
|
|
||||||
[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[] = {
|
||||||
|
/* 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)
|
* Default colors (colorname index)
|
||||||
* foreground, background, cursor, reverse cursor
|
* foreground, background, cursor, reverse cursor
|
||||||
*/
|
*/
|
||||||
static unsigned int defaultfg = 7;
|
static unsigned int defaultfg = 12;
|
||||||
static unsigned int defaultbg = 0;
|
static unsigned int defaultbg = 8;
|
||||||
static unsigned int defaultcs = 256;
|
static unsigned int defaultcs = 14;
|
||||||
static unsigned int defaultrcs = 257;
|
static unsigned int defaultrcs = 15;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default shape of cursor
|
* Default shape of cursor
|
||||||
@ -184,6 +196,7 @@ static Shortcut shortcuts[] = {
|
|||||||
{ MODKEY|ShiftMask, XK_V, clippaste, {.i = 0} },
|
{ MODKEY|ShiftMask, XK_V, clippaste, {.i = 0} },
|
||||||
{ MODKEY, XK_Num_Lock, numlock, {.i = 0} },
|
{ MODKEY, XK_Num_Lock, numlock, {.i = 0} },
|
||||||
{ MODKEY, XK_Control_L, iso14755, {.i = 0} },
|
{ MODKEY, XK_Control_L, iso14755, {.i = 0} },
|
||||||
|
{ XK_ANY_MOD, XK_F6, swapcolors, {.i = 0} },
|
||||||
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
|
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
|
||||||
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
|
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
|
||||||
};
|
};
|
||||||
|
30
st.c
30
st.c
@ -351,6 +351,7 @@ static void clippaste(const Arg *);
|
|||||||
static void kscrolldown(const Arg *);
|
static void kscrolldown(const Arg *);
|
||||||
static void kscrollup(const Arg *);
|
static void kscrollup(const Arg *);
|
||||||
static void numlock(const Arg *);
|
static void numlock(const Arg *);
|
||||||
|
static void swapcolors(const Arg *);
|
||||||
static void selpaste(const Arg *);
|
static void selpaste(const Arg *);
|
||||||
static void xzoom(const Arg *);
|
static void xzoom(const Arg *);
|
||||||
static void xzoomabs(const Arg *);
|
static void xzoomabs(const Arg *);
|
||||||
@ -381,7 +382,7 @@ typedef struct {
|
|||||||
|
|
||||||
/* Drawing Context */
|
/* Drawing Context */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Color col[MAX(LEN(colorname), 256)];
|
Color col[MAX(MAX(LEN(colorname), LEN(altcolorname)), 256)];
|
||||||
Font font, bfont, ifont, ibfont;
|
Font font, bfont, ifont, ibfont;
|
||||||
GC gc;
|
GC gc;
|
||||||
} DC;
|
} DC;
|
||||||
@ -560,6 +561,8 @@ static char *opt_name = NULL;
|
|||||||
static char *opt_title = NULL;
|
static char *opt_title = NULL;
|
||||||
static int oldbutton = 3; /* button event on startup: 3 = release */
|
static int oldbutton = 3; /* button event on startup: 3 = release */
|
||||||
|
|
||||||
|
static int usealtcolors = 0; /* 1 to use alternate palette */
|
||||||
|
|
||||||
static char *usedfont = NULL;
|
static char *usedfont = NULL;
|
||||||
static double usedfontsize = 0;
|
static double usedfontsize = 0;
|
||||||
static double defaultfontsize = 0;
|
static double defaultfontsize = 0;
|
||||||
@ -3334,6 +3337,11 @@ sixd_to_16bit(int x)
|
|||||||
return x == 0 ? 0 : 0x3737 + 0x2828 * x;
|
return x == 0 ? 0 : 0x3737 + 0x2828 * x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* getcolorname(int i)
|
||||||
|
{
|
||||||
|
return (usealtcolors) ? altcolorname[i] : colorname[i];
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
xloadcolor(int i, const char *name, Color *ncolor)
|
xloadcolor(int i, const char *name, Color *ncolor)
|
||||||
{
|
{
|
||||||
@ -3352,7 +3360,7 @@ xloadcolor(int i, const char *name, Color *ncolor)
|
|||||||
return XftColorAllocValue(xw.dpy, xw.vis,
|
return XftColorAllocValue(xw.dpy, xw.vis,
|
||||||
xw.cmap, &color, ncolor);
|
xw.cmap, &color, ncolor);
|
||||||
} else
|
} else
|
||||||
name = colorname[i];
|
name = getcolorname(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
|
return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
|
||||||
@ -3372,8 +3380,8 @@ xloadcols(void)
|
|||||||
|
|
||||||
for (i = 0; i < LEN(dc.col); i++)
|
for (i = 0; i < LEN(dc.col); i++)
|
||||||
if (!xloadcolor(i, NULL, &dc.col[i])) {
|
if (!xloadcolor(i, NULL, &dc.col[i])) {
|
||||||
if (colorname[i])
|
if (getcolorname(i))
|
||||||
die("Could not allocate color '%s'\n", colorname[i]);
|
die("Could not allocate color '%s'\n", getcolorname(i));
|
||||||
else
|
else
|
||||||
die("Could not allocate color %d\n", i);
|
die("Could not allocate color %d\n", i);
|
||||||
}
|
}
|
||||||
@ -3740,13 +3748,13 @@ xinit(void)
|
|||||||
cursor = XCreateFontCursor(xw.dpy, mouseshape);
|
cursor = XCreateFontCursor(xw.dpy, mouseshape);
|
||||||
XDefineCursor(xw.dpy, xw.win, cursor);
|
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.red = 0xffff;
|
||||||
xmousefg.green = 0xffff;
|
xmousefg.green = 0xffff;
|
||||||
xmousefg.blue = 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.red = 0x0000;
|
||||||
xmousebg.green = 0x0000;
|
xmousebg.green = 0x0000;
|
||||||
xmousebg.blue = 0x0000;
|
xmousebg.blue = 0x0000;
|
||||||
@ -3944,7 +3952,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
|
|||||||
|
|
||||||
/* Change basic system colors [0-7] to bright system colors [8-15] */
|
/* Change basic system colors [0-7] to bright system colors [8-15] */
|
||||||
if ((base.mode & ATTR_BOLD_FAINT) == ATTR_BOLD && BETWEEN(base.fg, 0, 7))
|
if ((base.mode & ATTR_BOLD_FAINT) == ATTR_BOLD && BETWEEN(base.fg, 0, 7))
|
||||||
fg = &dc.col[base.fg + 8];
|
fg = &dc.col[base.fg];
|
||||||
|
|
||||||
if (IS_SET(MODE_REVERSE)) {
|
if (IS_SET(MODE_REVERSE)) {
|
||||||
if (fg == &dc.col[defaultfg]) {
|
if (fg == &dc.col[defaultfg]) {
|
||||||
@ -4301,6 +4309,14 @@ numlock(const Arg *dummy)
|
|||||||
term.numlock ^= 1;
|
term.numlock ^= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
swapcolors(const Arg *dummy)
|
||||||
|
{
|
||||||
|
usealtcolors = !usealtcolors;
|
||||||
|
xloadcols();
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
kmap(KeySym k, uint state)
|
kmap(KeySym k, uint state)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user