Simplify cursor color handling
authorJules Maselbas <jules.maselbas@grenoble-inp.org>
Sat, 14 Jul 2018 09:16:36 +0000 (11:16 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Sat, 14 Jul 2018 10:49:35 +0000 (12:49 +0200)
x.c

diff --git a/x.c b/x.c
index 00cb6b1..ffd005f 100644 (file)
--- a/x.c
+++ b/x.c
@@ -1418,25 +1418,19 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
         */
        g.mode &= ATTR_BOLD|ATTR_ITALIC|ATTR_UNDERLINE|ATTR_STRUCK|ATTR_WIDE;
 
-       if (IS_SET(MODE_REVERSE)) {
-               g.mode |= ATTR_REVERSE;
-               g.bg = defaultfg;
-               if (selected(cx, cy)) {
-                       drawcol = dc.col[defaultcs];
-                       g.fg = defaultrcs;
-               } else {
-                       drawcol = dc.col[defaultrcs];
-                       g.fg = defaultcs;
-               }
+       if (selected(cx, cy)) {
+               g.bg = defaultrcs;
+               g.fg = defaultfg;
        } else {
-               if (selected(cx, cy)) {
-                       g.fg = defaultfg;
-                       g.bg = defaultrcs;
-               } else {
-                       g.fg = defaultbg;
-                       g.bg = defaultcs;
-               }
-               drawcol = dc.col[g.bg];
+               g.bg = defaultcs;
+               g.fg = defaultbg;
+       }
+       drawcol = dc.col[g.bg];
+
+       if (IS_SET(MODE_REVERSE)) {
+               drawcol.color.red = ~drawcol.color.red;
+               drawcol.color.green = ~drawcol.color.green;
+               drawcol.color.blue = ~drawcol.color.blue;
        }
 
        /* draw the new one */