commit 1543a443ad5f6254b82451b07a55a27308cfb125 parent 2c38063ea3a78f0424e746ac382d927f6edc24c7 Author: Matthew Parnell <matt@parnmatt.co.uk> Date: Wed, 2 Aug 2017 18:19:52 +0100 Update st patches for 0.7 & X-specific code split Several patches had yet to have a 0.7 version, and applying 0.6- or closest git-patch failed. Since st:e2ee5ee, X-specific code has been split into x.c; breaking several patches. copyurl relies on an X-specific function; a quick hack is in place to keep functionality; original author / current maintainer should investigate alternative approach. visualbell was not updated due to relying on a X-specific struct, and I did not want to pollute the code with repeat struct definitions. Original author / current maintainer should investigate further. Diffstat:
15 files changed, 469 insertions(+), 0 deletions(-)
diff --git a/st.suckless.org/patches/alpha.md b/st.suckless.org/patches/alpha.md @@ -23,6 +23,7 @@ Download * [st-alpha-0.4.1.diff](st-alpha-0.4.1.diff) * [st-alpha-0.5.diff](st-alpha-0.5.diff) * [st-alpha-0.6.diff](st-alpha-0.6.diff) + * [st-alpha-0.7.diff](st-alpha-0.7.diff) * [st-alpha-20160727-308bfbf.diff](st-alpha-20160727-308bfbf.diff) * [st-alpha-20170509-5a10aca.diff](st-alpha-20170509-5a10aca.diff) @@ -33,3 +34,4 @@ Authors * pr - <protodev@gmx.net> (0.5 port) * Laslo Hunhold - <dev@frign.de> (0.6, git ports) * Ivan J. - <parazyd@dyne.org> (git port) + * Matthew Parnell - <matt@parnmatt.co.uk> (0.7 port) diff --git a/st.suckless.org/patches/clipboard.md b/st.suckless.org/patches/clipboard.md @@ -16,10 +16,13 @@ Download -------- * [st-clipboard-0.6.diff](st-clipboard-0.6.diff) +* [st-clipboard-0.7.diff](st-clipboard-0.7.diff) * [st-clipboard-20160727-308bfbf.diff](st-clipboard-20160727-308bfbf.diff) +* [st-clipboard-20170802-e2ee5ee.diff](st-clipboard-20170802-e2ee5ee.diff) Authors ------- * Kai Hendry - <hendry@iki.fi> * Laslo Hunhold - <dev@frign.de> (git port) + * Matthew Parnell - <matt@parnmatt.co.uk> (0.7, git ports) diff --git a/st.suckless.org/patches/copyurl.md b/st.suckless.org/patches/copyurl.md @@ -17,7 +17,9 @@ Download -------- * [st-copyurl-0.6.diff](st-copyurl-0.6.diff) + * [st-copyurl-0.7.diff](st-copyurl-0.7.diff) * [st-copyurl-20161105-8c99915.diff](st-copyurl-20161105-8c99915.diff) + * [st-copyurl-20170802-e2ee5ee.diff](st-copyurl-20170802-e2ee5ee.diff) Authors ------- @@ -25,3 +27,4 @@ Authors * Brandon Mulcahy - <brandon@jangler.info> * Laslo Hunhold - <dev@frign.de> (0.6 port) * David Phillips - <david@sighup.nz> (git port) + * Matthew Parnell - <matt@parnmatt.co.uk> (0.7, git ports) diff --git a/st.suckless.org/patches/delkey.md b/st.suckless.org/patches/delkey.md @@ -10,6 +10,7 @@ Download -------- * [st-delkey-0.6.diff](st-delkey-0.6.diff) + * [st-delkey-0.7.diff](st-delkey-0.7.diff) * [st-delkey-20160727-308bfbf.diff](st-delkey-20160727-308bfbf.diff) Authors @@ -17,3 +18,4 @@ Authors * Roberto E. Vargas Caballero - <k0ga@shike2.com> * Laslo Hunhold - <dev@frign.de> (0.6, git ports) + * Matthew Parnell - <matt@parnmatt.co.uk> (0.7 port) diff --git a/st.suckless.org/patches/solarized.md b/st.suckless.org/patches/solarized.md @@ -34,6 +34,7 @@ to disable lighting up bold colors. * [st-no_bold_colors-0.5.diff](st-no_bold_colors-0.5.diff) * [st-no_bold_colors-0.6.diff](st-no_bold_colors-0.6.diff) + * [st-no_bold_colors-0.7.diff](st-no_bold_colors-0.7.diff) * [st-no_bold_colors-20170623-b331da5.diff](st-no_bold_colors-20170623-b331da5.diff) Choose one of the following patches to get either the light @@ -43,12 +44,14 @@ or the dark color scheme: * [st-solarized-light-0.5.diff](st-solarized-light-0.5.diff) * [st-solarized-light-0.6.diff](st-solarized-light-0.6.diff) + * [st-solarized-light-0.7.diff](st-solarized-light-0.7.diff) * [st-solarized-light-20170623-b331da5.diff](st-solarized-light-20170623-b331da5.diff) *Dark*: * [st-solarized-dark-0.5.diff](st-solarized-dark-0.5.diff) * [st-solarized-dark-0.6.diff](st-solarized-dark-0.6.diff) + * [st-solarized-dark-0.7.diff](st-solarized-dark-0.7.diff) * [st-solarized-dark-20170623-b331da5.diff](st-solarized-dark-20170623-b331da5.diff) *Both (swap between light/dark with F6)*: @@ -63,3 +66,4 @@ Authors * Ryan Roden-Corrent - <ryan@rcorre.net> (both) * Marcel Krüger - <zauguin@gmail.com> (older git ports) * Harry Gindi - <harry.gindi@live.com> (git ports for light, dark, and swap versions) + * Matthew Parnell - <matt@parnmatt.co.uk> (0.7 port) diff --git a/st.suckless.org/patches/spoiler.md b/st.suckless.org/patches/spoiler.md @@ -20,10 +20,13 @@ Download -------- * [st-spoiler-0.6.diff](st-spoiler-0.6.diff) + * [st-spoiler-0.7.diff](st-spoiler-0.7.diff) * [st-spoiler-20160727-308bfbf.diff](st-spoiler-20160727-308bfbf.diff) + * [st-spoiler-20170802-e2ee5ee.diff](st-spoiler-20170802-e2ee5ee.diff) Author ------ * dequis - <dx@dxzone.com.ar> * Laslo Hunhold - <dev@frign.de> (git port) + * Matthew Parnell - <matt@parnmatt.co.uk> (0.7, git ports) diff --git a/st.suckless.org/patches/st-alpha-0.7.diff b/st.suckless.org/patches/st-alpha-0.7.diff @@ -0,0 +1,188 @@ +diff --git a/config.def.h b/config.def.h +index b41747f..e22ebd2 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -82,6 +82,9 @@ static char termname[] = "st-256color"; + */ + static unsigned int tabspaces = 8; + ++/* bg opacity */ ++static const int alpha = 0xdd; ++ + /* Terminal colors (16 first used in escape sequence) */ + static const char *colorname[] = { + /* 8 normal colors */ +@@ -109,6 +112,7 @@ static const char *colorname[] = { + /* more colors can be added after 255 to use with DefaultXX */ + "#cccccc", + "#555555", ++ "black", + }; + + +@@ -117,7 +121,7 @@ static const char *colorname[] = { + * foreground, background, cursor, reverse cursor + */ + static unsigned int defaultfg = 7; +-static unsigned int defaultbg = 0; ++static unsigned int defaultbg = 257; + static unsigned int defaultcs = 256; + static unsigned int defaultrcs = 257; + +diff --git a/config.mk b/config.mk +index c84c5ee..19a03bb 100644 +--- a/config.mk ++++ b/config.mk +@@ -14,7 +14,7 @@ X11LIB = /usr/X11R6/lib + INCS = -I. -I/usr/include -I${X11INC} \ + `pkg-config --cflags fontconfig` \ + `pkg-config --cflags freetype2` +-LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lrt -lX11 -lutil -lXft \ ++LIBS = -L/usr/lib -lc -L${X11LIB} -lm -lrt -lX11 -lutil -lXext -lXft -lXrender\ + `pkg-config --libs fontconfig` \ + `pkg-config --libs freetype2` + +diff --git a/st.c b/st.c +index 2594c65..f9ba75b 100644 +--- a/st.c ++++ b/st.c +@@ -61,6 +61,7 @@ char *argv0; + #define XK_ANY_MOD UINT_MAX + #define XK_NO_MOD 0 + #define XK_SWITCH_MOD (1<<13) ++#define OPAQUE 0Xff + + /* macros */ + #define MIN(a, b) ((a) < (b) ? (a) : (b)) +@@ -81,6 +82,8 @@ char *argv0; + (t1.tv_nsec-t2.tv_nsec)/1E6) + #define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit))) + ++#define USE_ARGB (alpha != OPAQUE && opt_embed == NULL) ++ + #define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b)) + #define IS_TRUECOL(x) (1 << 24 & (x)) + #define TRUERED(x) (((x) & 0xff0000) >> 8) +@@ -268,6 +271,7 @@ typedef struct { + int w, h; /* window width and height */ + int ch; /* char height */ + int cw; /* char width */ ++ int depth; /* bit depth */ + char state; /* focus, redraw, visible */ + int cursor; /* cursor style */ + } XWindow; +@@ -3137,7 +3141,7 @@ xresize(int col, int row) + + XFreePixmap(xw.dpy, xw.buf); + xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, +- DefaultDepth(xw.dpy, xw.scr)); ++ xw.depth); + XftDrawChange(xw.draw, xw.buf); + xclear(0, 0, xw.w, xw.h); + } +@@ -3191,6 +3195,14 @@ xloadcols(void) + else + die("Could not allocate color %d\n", i); + } ++ ++ /* set alpha value of bg color */ ++ if (USE_ARGB) { ++ dc.col[defaultbg].color.alpha = (0xffff * alpha) / OPAQUE; //0xcccc; ++ dc.col[defaultbg].pixel &= 0x00111111; ++ dc.col[defaultbg].pixel |= alpha << 24; // 0xcc000000; ++ } ++ + loaded = 1; + } + +@@ -3212,6 +3224,16 @@ xsetcolorname(int x, const char *name) + return 0; + } + ++void ++xtermclear(int col1, int row1, int col2, int row2) { ++ XftDrawRect(xw.draw, ++ &dc.col[IS_SET(MODE_REVERSE) ? defaultfg : defaultbg], ++ borderpx + col1 * xw.cw, ++ borderpx + row1 * xw.ch, ++ (col2-col1+1) * xw.cw, ++ (row2-row1+1) * xw.ch); ++} ++ + /* + * Absolute coordinates. + */ +@@ -3443,7 +3465,38 @@ xinit(void) + if (!(xw.dpy = XOpenDisplay(NULL))) + die("Can't open display\n"); + xw.scr = XDefaultScreen(xw.dpy); +- xw.vis = XDefaultVisual(xw.dpy, xw.scr); ++ xw.depth = (USE_ARGB) ? 32: XDefaultDepth(xw.dpy, xw.scr); ++ if (! USE_ARGB) ++ xw.vis = XDefaultVisual(xw.dpy, xw.scr); ++ else { ++ XVisualInfo *vis; ++ XRenderPictFormat *fmt; ++ int nvi; ++ int i; ++ ++ XVisualInfo tpl = { ++ .screen = xw.scr, ++ .depth = 32, ++ .class = TrueColor ++ }; ++ ++ vis = XGetVisualInfo(xw.dpy, VisualScreenMask | VisualDepthMask | VisualClassMask, &tpl, &nvi); ++ xw.vis = NULL; ++ for(i = 0; i < nvi; i ++) { ++ fmt = XRenderFindVisualFormat(xw.dpy, vis[i].visual); ++ if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) { ++ xw.vis = vis[i].visual; ++ break; ++ } ++ } ++ ++ XFree(vis); ++ ++ if (! xw.vis) { ++ fprintf(stderr, "Couldn't find ARGB visual.\n"); ++ exit(1); ++ } ++ } + + /* font */ + if (!FcInit()) +@@ -3453,7 +3506,10 @@ xinit(void) + xloadfonts(usedfont, 0); + + /* colors */ +- xw.cmap = XDefaultColormap(xw.dpy, xw.scr); ++ if (! USE_ARGB) ++ xw.cmap = XDefaultColormap(xw.dpy, xw.scr); ++ else ++ xw.cmap = XCreateColormap(xw.dpy, XRootWindow(xw.dpy, xw.scr), xw.vis, None); + xloadcols(); + + /* adjust fixed window geometry */ +@@ -3476,16 +3532,17 @@ xinit(void) + if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0)))) + parent = XRootWindow(xw.dpy, xw.scr); + xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t, +- xw.w, xw.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput, ++ xw.w, xw.h, 0, xw.depth, InputOutput, + xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity + | CWEventMask | CWColormap, &xw.attrs); + + memset(&gcvalues, 0, sizeof(gcvalues)); + gcvalues.graphics_exposures = False; +- dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures, ++ xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, xw.depth); ++ dc.gc = XCreateGC(xw.dpy, ++ (USE_ARGB)? xw.buf: parent, ++ GCGraphicsExposures, + &gcvalues); +- xw.buf = XCreatePixmap(xw.dpy, xw.win, xw.w, xw.h, +- DefaultDepth(xw.dpy, xw.scr)); + XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel); + XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, xw.w, xw.h); + diff --git a/st.suckless.org/patches/st-clipboard-0.7.diff b/st.suckless.org/patches/st-clipboard-0.7.diff @@ -0,0 +1,13 @@ +diff --git a/st.c b/st.c +index 2594c65..ebdde9f 100644 +--- a/st.c ++++ b/st.c +@@ -1263,6 +1263,8 @@ xsetsel(char *str, Time t) + XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t); + if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win) + selclear(0); ++ ++ clipcopy(NULL); + } + + void diff --git a/st.suckless.org/patches/st-clipboard-20170802-e2ee5ee.diff b/st.suckless.org/patches/st-clipboard-20170802-e2ee5ee.diff @@ -0,0 +1,13 @@ +diff --git a/x.c b/x.c +index 6474a01..aab6070 100644 +--- a/x.c ++++ b/x.c +@@ -508,6 +508,8 @@ xsetsel(char *str, Time t) + XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t); + if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win) + selclear_(NULL); ++ ++ clipcopy(NULL); + } + + void diff --git a/st.suckless.org/patches/st-delkey-0.7.diff b/st.suckless.org/patches/st-delkey-0.7.diff @@ -0,0 +1,45 @@ +diff --git a/config.def.h b/config.def.h +index b41747f..1b52a86 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -261,7 +261,7 @@ static Key key[] = { + { XK_KP_Delete, ShiftMask, "\033[2K", -1, 0, 0}, + { XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0, 0}, + { XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0}, +- { XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0}, ++ { XK_KP_Delete, XK_ANY_MOD, "\177", +1, 0, 0}, + { XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0, 0}, + { XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0, 0}, + { XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0, 0}, +@@ -316,8 +316,7 @@ static Key key[] = { + { XK_Delete, ShiftMask, "\033[2K", -1, 0, 0}, + { XK_Delete, ShiftMask, "\033[3;2~", +1, 0, 0}, + { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0, 0}, +- { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0, 0}, +- { XK_BackSpace, XK_NO_MOD, "\177", 0, 0, 0}, ++ { XK_Delete, XK_ANY_MOD, "\177", +1, 0, 0}, + { XK_BackSpace, Mod1Mask, "\033\177", 0, 0, 0}, + { XK_Home, ShiftMask, "\033[2J", 0, -1, 0}, + { XK_Home, ShiftMask, "\033[1;2H", 0, +1, 0}, +diff --git a/st.info b/st.info +index b70fefa..d979946 100644 +--- a/st.info ++++ b/st.info +@@ -53,7 +53,7 @@ st| simpleterm, + ka3=\E[5~, + kc1=\E[4~, + kc3=\E[6~, +- kbs=\177, ++ kbs=\010, + kcbt=\E[Z, + kb2=\EOu, + kcub1=\EOD, +@@ -73,7 +73,7 @@ st| simpleterm, + kri=\E[1;2A, + kclr=\E[3;5~, + kdl1=\E[3;2~, +- kdch1=\E[3~, ++ kdch1=\177~, + kich1=\E[2~, + kend=\E[4~, + kf1=\EOP, diff --git a/st.suckless.org/patches/st-no_bold_colors-0.7.diff b/st.suckless.org/patches/st-no_bold_colors-0.7.diff @@ -0,0 +1,13 @@ +diff --git a/st.c b/st.c +index 2594c65..f6fe717 100644 +--- a/st.c ++++ b/st.c +@@ -3719,7 +3719,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]) { diff --git a/st.suckless.org/patches/st-solarized-dark-0.7.diff b/st.suckless.org/patches/st-solarized-dark-0.7.diff @@ -0,0 +1,68 @@ +diff --git a/config.def.h b/config.def.h +index b41747f..8bdcc87 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -84,31 +84,23 @@ static 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", +- +- [255] = 0, +- +- /* more colors can be added after 255 to use with DefaultXX */ +- "#cccccc", +- "#555555", ++ /* solarized dark */ ++ "#073642", /* 0: black */ ++ "#dc322f", /* 1: red */ ++ "#859900", /* 2: green */ ++ "#b58900", /* 3: yellow */ ++ "#268bd2", /* 4: blue */ ++ "#d33682", /* 5: magenta */ ++ "#2aa198", /* 6: cyan */ ++ "#eee8d5", /* 7: white */ ++ "#002b36", /* 8: brblack */ ++ "#cb4b16", /* 9: brred */ ++ "#586e75", /* 10: brgreen */ ++ "#657b83", /* 11: bryellow */ ++ "#839496", /* 12: brblue */ ++ "#6c71c4", /* 13: brmagenta*/ ++ "#93a1a1", /* 14: brcyan */ ++ "#fdf6e3", /* 15: brwhite */ + }; + + +@@ -116,10 +108,10 @@ static const char *colorname[] = { + * Default colors (colorname index) + * foreground, background, cursor, reverse cursor + */ +-static unsigned int defaultfg = 7; +-static unsigned int defaultbg = 0; +-static unsigned int defaultcs = 256; +-static unsigned int defaultrcs = 257; ++static unsigned int defaultfg = 12; ++static unsigned int defaultbg = 8; ++static unsigned int defaultcs = 14; ++static unsigned int defaultrcs = 15; + + /* + * Default shape of cursor diff --git a/st.suckless.org/patches/st-solarized-light-0.7.diff b/st.suckless.org/patches/st-solarized-light-0.7.diff @@ -0,0 +1,68 @@ +diff --git a/config.def.h b/config.def.h +index b41747f..5a87570 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -84,31 +84,23 @@ static 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", +- +- [255] = 0, +- +- /* more colors can be added after 255 to use with DefaultXX */ +- "#cccccc", +- "#555555", ++ /* 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 */ + }; + + +@@ -116,10 +108,10 @@ static const char *colorname[] = { + * Default colors (colorname index) + * foreground, background, cursor, reverse cursor + */ +-static unsigned int defaultfg = 7; +-static unsigned int defaultbg = 0; +-static unsigned int defaultcs = 256; +-static unsigned int defaultrcs = 257; ++static unsigned int defaultfg = 12; ++static unsigned int defaultbg = 8; ++static unsigned int defaultcs = 14; ++static unsigned int defaultrcs = 15; + + /* + * Default shape of cursor diff --git a/st.suckless.org/patches/st-spoiler-0.7.diff b/st.suckless.org/patches/st-spoiler-0.7.diff @@ -0,0 +1,22 @@ +diff --git a/st.c b/st.c +index 2594c65..742bc5c 100644 +--- a/st.c ++++ b/st.c +@@ -3748,9 +3748,14 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i + } + + if (base.mode & ATTR_REVERSE) { +- temp = fg; +- fg = bg; +- bg = temp; ++ if (bg == fg) { ++ bg = &dc.col[defaultfg]; ++ fg = &dc.col[defaultbg]; ++ } else { ++ temp = fg; ++ fg = bg; ++ bg = temp; ++ } + } + + if ((base.mode & ATTR_BOLD_FAINT) == ATTR_FAINT) { diff --git a/st.suckless.org/patches/st-spoiler-20170802-e2ee5ee.diff b/st.suckless.org/patches/st-spoiler-20170802-e2ee5ee.diff @@ -0,0 +1,22 @@ +diff --git a/x.c b/x.c +index 6474a01..8ecfec0 100644 +--- a/x.c ++++ b/x.c +@@ -1188,9 +1188,14 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i + } + + if (base.mode & ATTR_REVERSE) { +- temp = fg; +- fg = bg; +- bg = temp; ++ if (bg == fg) { ++ bg = &dc.col[defaultfg]; ++ fg = &dc.col[defaultbg]; ++ } else { ++ temp = fg; ++ fg = bg; ++ bg = temp; ++ } + } + + if ((base.mode & ATTR_BOLD_FAINT) == ATTR_FAINT) {