JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Drawing a more visible rectangle as cursor on unfocus.
authorChristoph Lohmann <20h@r-36.net>
Sat, 13 Apr 2013 07:44:00 +0000 (09:44 +0200)
committerChristoph Lohmann <20h@r-36.net>
Sat, 13 Apr 2013 07:44:00 +0000 (09:44 +0200)
To have a more visible cursor on unfocused windows this patch makes st draw a
rectangle around the terminal cell.

Thanks Mark Hills <mark@xwax.org> for the suggestion!

config.def.h
st.c

index 2c97266..d1c20bd 100644 (file)
@@ -52,18 +52,16 @@ static const char *colorname[] = {
 
        /* more colors can be added after 255 to use with DefaultXX */
        "#cccccc",
-       "#333333",
 };
 
 
 /*
  * Default colors (colorname index)
- * foreground, background, cursor, unfocused cursor
+ * foreground, background, cursor
  */
 static unsigned int defaultfg = 7;
 static unsigned int defaultbg = 0;
 static unsigned int defaultcs = 256;
-static unsigned int defaultucs = 257;
 
 /*
  * Colors used, when the specific fg == defaultfg. So in reverse mode this
diff --git a/st.c b/st.c
index 23a43c1..c4eafa0 100644 (file)
--- a/st.c
+++ b/st.c
@@ -2968,14 +2968,33 @@ xdrawcursor(void) {
 
        /* draw the new one */
        if(!(IS_SET(MODE_HIDE))) {
-               if(!(xw.state & WIN_FOCUSED))
-                       g.bg = defaultucs;
-
-               if(IS_SET(MODE_REVERSE))
-                       g.mode |= ATTR_REVERSE, g.fg = defaultcs, g.bg = defaultfg;
+               if(xw.state & WIN_FOCUSED) {
+                       if(IS_SET(MODE_REVERSE)) {
+                               g.mode |= ATTR_REVERSE;
+                               g.fg = defaultcs;
+                               g.bg = defaultfg;
+                       }
 
-               sl = utf8size(g.c);
-               xdraws(g.c, g, term.c.x, term.c.y, 1, sl);
+                       sl = utf8size(g.c);
+                       xdraws(g.c, g, term.c.x, term.c.y, 1, sl);
+               } else {
+                       XftDrawRect(xw.draw, &dc.col[defaultcs],
+                                       borderpx + term.c.x * xw.cw,
+                                       borderpx + term.c.y * xw.ch,
+                                       xw.cw - 1, 1);
+                       XftDrawRect(xw.draw, &dc.col[defaultcs],
+                                       borderpx + term.c.x * xw.cw,
+                                       borderpx + term.c.y * xw.ch,
+                                       1, xw.ch - 1);
+                       XftDrawRect(xw.draw, &dc.col[defaultcs],
+                                       borderpx + (term.c.x + 1) * xw.cw - 1,
+                                       borderpx + term.c.y * xw.ch,
+                                       1, xw.ch - 1);
+                       XftDrawRect(xw.draw, &dc.col[defaultcs],
+                                       borderpx + term.c.x * xw.cw,
+                                       borderpx + (term.c.y + 1) * xw.ch - 1,
+                                       xw.cw, 1);
+               }
                oldx = term.c.x, oldy = term.c.y;
        }
 }