aboutsummaryrefslogtreecommitdiffstats
path: root/x.c
diff options
context:
space:
mode:
Diffstat (limited to 'x.c')
-rw-r--r--x.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/x.c b/x.c
index 120e495..2f16fc3 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)
{
@@ -293,6 +296,14 @@ numlock(const Arg *dummy)
}
void
+swapcolors(const Arg *dummy)
+{
+ usealtcolors = !usealtcolors;
+ xloadcols();
+ redraw();
+}
+
+void
zoom(const Arg *arg)
{
Arg larg;
@@ -748,6 +759,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)
{
@@ -766,7 +782,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);
@@ -789,8 +805,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);
}
@@ -1169,13 +1185,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;
@@ -1383,7 +1399,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
/* 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))
- fg = &dc.col[base.fg + 8];
+ fg = &dc.col[base.fg];
if (IS_SET(MODE_REVERSE)) {
if (fg == &dc.col[defaultfg]) {
@@ -1609,6 +1625,8 @@ xsettitle(char *p)
int
xstartdraw(void)
{
+ if (IS_SET(MODE_VISIBLE))
+ XCopyArea(xw.dpy, xw.win, xw.buf, dc.gc, 0, 0, win.w, win.h, 0, 0);
return IS_SET(MODE_VISIBLE);
}
Un proyecto texto-plano.xyz