[dev] [st] [PATCH] Clearer cursor style, like xterm

From: Mark Hills <mark_AT_xwax.org>
Date: Fri, 12 Apr 2013 15:33:59 +0100

I find when a window is un-focused that the cursor location looks too
much like display content.

Please consider this patch, which mimics xterm behaviour by displaying
a hollow rectangle, and makes a saving of one colourmap entry :)
---
 config.def.h |  4 +---
 st.c         | 18 ++++++++++++------
 2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/config.def.h b/config.def.h
index 2c97266..d1c20bd 100644
--- a/config.def.h
+++ b/config.def.h
_AT_@ -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 93058b9..dac490f 100644
--- a/st.c
+++ b/st.c
_AT_@ -2945,14 +2945,20 @@ xdrawcursor(void) {
 
 	/* draw the new one */
 	if(!(IS_SET(MODE_HIDE))) {
-		if(!(xw.state & WIN_FOCUSED))
-			g.bg = defaultucs;
+		if(xw.state & WIN_FOCUSED) {
+			if(IS_SET(MODE_REVERSE))
+				g.mode |= ATTR_REVERSE, g.fg = defaultcs, g.bg = defaultfg;
 
-		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);
+		} else {
+			XSetForeground(xw.dpy, dc.gc, dc.col[defaultcs].pixel);
+			XDrawRectangle(xw.dpy, xw.buf, dc.gc,
+				borderpx + term.c.x * xw.cw,
+				borderpx + term.c.y * xw.ch,
+				xw.cw - 1, xw.ch - 1);
+		}
 
-		sl = utf8size(g.c);
-		xdraws(g.c, g, term.c.x, term.c.y, 1, sl);
 		oldx = term.c.x, oldy = term.c.y;
 	}
 }
-- 
1.7.12.1
Received on Fri Apr 12 2013 - 16:33:59 CEST

This archive was generated by hypermail 2.3.0 : Fri Apr 12 2013 - 16:36:06 CEST