[hackers] [st][PATCH] fix: width of cursor on wide glyph

From: yahei <yahei1423_AT_gmail.com>
Date: Tue, 13 May 2025 18:58:07 +0900

Make underline and unfocused cursors wide when the cursor is on a wide glyph.
---
 x.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/x.c b/x.c
index d73152b..fe08e25 100644
--- a/x.c
+++ b/x.c
_AT_@ -1522,6 +1522,7 @@ xdrawglyph(Glyph g, int x, int y)
 void
 xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
 {
+	int cwidth = win.cw * (g.mode & ATTR_WIDE ? 2 : 1);
 	Color drawcol;
 
 	/* remove the old cursor */
_AT_@ -1575,7 +1576,7 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
 					borderpx + cx * win.cw,
 					borderpx + (cy + 1) * win.ch - \
 						cursorthickness,
-					win.cw, cursorthickness);
+					cwidth, cursorthickness);
 			break;
 		case 5: /* Blinking bar */
 		case 6: /* Steady bar */
_AT_@ -1589,19 +1590,19 @@ xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
 		XftDrawRect(xw.draw, &drawcol,
 				borderpx + cx * win.cw,
 				borderpx + cy * win.ch,
-				win.cw - 1, 1);
+				cwidth - 1, 1);
 		XftDrawRect(xw.draw, &drawcol,
 				borderpx + cx * win.cw,
 				borderpx + cy * win.ch,
 				1, win.ch - 1);
 		XftDrawRect(xw.draw, &drawcol,
-				borderpx + (cx + 1) * win.cw - 1,
+				borderpx + cx * win.cw + cwidth - 1,
 				borderpx + cy * win.ch,
 				1, win.ch - 1);
 		XftDrawRect(xw.draw, &drawcol,
 				borderpx + cx * win.cw,
 				borderpx + (cy + 1) * win.ch - 1,
-				win.cw, 1);
+				cwidth, 1);
 	}
 }
 
-- 
2.49.0
Received on Tue May 13 2025 - 11:58:07 CEST

This archive was generated by hypermail 2.3.0 : Tue May 13 2025 - 17:24:40 CEST