[dev] [st] Support the DECSCUSR CSI escape sequence

From: LemonBoy <thatlemon_AT_gmail.com>
Date: Tue, 17 Mar 2015 21:04:32 +0100

---
 st.c | 47 ++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 38 insertions(+), 9 deletions(-)
diff --git a/st.c b/st.c
index 836ae21..37da82e 100644
--- a/st.c
+++ b/st.c
_AT_@ -257,6 +257,7 @@ typedef struct {
 	int ch; /* char height */
 	int cw; /* char width  */
 	char state; /* focus, redraw, visible */
+	int cursor; /* cursor style */
 } XWindow;
 
 typedef struct {
_AT_@ -2173,6 +2174,13 @@ csihandle(void) {
 	case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */
 		tcursor(CURSOR_LOAD);
 		break;
+	case 'q': /* DECSCUSR -- Set Cursor Style */
+		DEFAULT(csiescseq.arg[0], 1);
+		if (!BETWEEN(csiescseq.arg[0], 0, 6)) {
+			goto unknown;
+		}
+		xw.cursor = csiescseq.arg[0];
+		break;
 	}
 }
 
_AT_@ -3553,16 +3561,36 @@ xdrawcursor(void) {
 
 	/* draw the new one */
 	if(xw.state & WIN_FOCUSED) {
-		if(IS_SET(MODE_REVERSE)) {
-			g.mode |= ATTR_REVERSE;
-			g.fg = defaultcs;
-			g.bg = defaultfg;
-		}
+		switch (xw.cursor) {
+			case 0: // Blinking Block
+			case 1: // Blinking Block (Default)
+			case 2: // Steady Block
+				if(IS_SET(MODE_REVERSE)) {
+						g.mode |= ATTR_REVERSE;
+						g.fg = defaultcs;
+						g.bg = defaultfg;
+					}
 
-		sl = utf8len(g.c);
-		width = (term.line[term.c.y][curx].mode & ATTR_WIDE)\
-			? 2 : 1;
-		xdraws(g.c, g, term.c.x, term.c.y, width, sl);
+				sl = utf8len(g.c);
+				width = (term.line[term.c.y][curx].mode & ATTR_WIDE)\
+					? 2 : 1;
+				xdraws(g.c, g, term.c.x, term.c.y, width, sl);
+				break;
+			case 3: /* Blinking Underline */
+			case 4: /* Steady Underline */
+				XftDrawRect(xw.draw, &dc.col[defaultcs],
+						borderpx + curx * xw.cw,
+						borderpx + (term.c.y + 1) * xw.ch - 1,
+						xw.cw, 1);
+				break;
+			case 5: /* Blinking bar */
+			case 6: /* Steady bar */
+				XftDrawRect(xw.draw, &dc.col[defaultcs],
+								borderpx + curx * xw.cw,
+								borderpx + term.c.y * xw.ch,
+								1, xw.ch);
+				break;
+		}
 	} else {
 		XftDrawRect(xw.draw, &dc.col[defaultcs],
 				borderpx + curx * xw.cw,
_AT_@ -3987,6 +4015,7 @@ main(int argc, char *argv[]) {
 
 	xw.l = xw.t = 0;
 	xw.isfixed = False;
+	xw.cursor = 0;
 
 	ARGBEGIN {
 	case 'a':
-- 
2.3.3
Received on Tue Mar 17 2015 - 21:04:32 CET

This archive was generated by hypermail 2.3.0 : Tue Mar 17 2015 - 21:12:07 CET