[hackers] [st][PATCH 10/23] Move cursor shape from TermWindow to Term

From: Devin J. Pohly <djpohly_AT_gmail.com>
Date: Sun, 24 Sep 2017 16:11:32 -0500

---
 st.c | 7 ++++---
 st.h | 4 ++--
 x.c  | 5 ++---
 3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/st.c b/st.c
index 341ad7d..be1666e 100644
--- a/st.c
+++ b/st.c
_AT_@ -973,9 +973,10 @@ treset(void)
 }
 
 void
-tnew(int col, int row)
+tnew(int col, int row, unsigned int cursor)
 {
-	term = (Term){ .c = { .attr = { .fg = defaultfg, .bg = defaultbg } } };
+	term = (Term){ .c = { .attr = { .fg = defaultfg, .bg = defaultbg } },
+		.cursor = cursor };
 	tresize(col, row);
 	term.numlock = 1;
 
_AT_@ -1745,7 +1746,7 @@ csihandle(void)
 			if (!BETWEEN(csiescseq.arg[0], 0, 6)) {
 				goto unknown;
 			}
-			win.cursor = csiescseq.arg[0];
+			term.cursor = csiescseq.arg[0];
 			break;
 		default:
 			goto unknown;
diff --git a/st.h b/st.h
index 0cfffa5..ede19e3 100644
--- a/st.h
+++ b/st.h
_AT_@ -115,6 +115,7 @@ typedef struct {
 	int *dirty;  /* dirtyness of lines */
 	GlyphFontSpec *specbuf; /* font spec buffer used for rendering */
 	TCursor c;    /* cursor */
+	int cursor;   /* cursor style */
 	int top;      /* top    scroll limit */
 	int bot;      /* bottom scroll limit */
 	int mode;     /* terminal mode flags */
_AT_@ -133,7 +134,6 @@ typedef struct {
 	int ch; /* char height */
 	int cw; /* char width  */
 	char state; /* focus, redraw, visible */
-	int cursor; /* cursor style */
 } TermWindow;
 
 typedef struct {
_AT_@ -183,7 +183,7 @@ void die(const char *, ...);
 void redraw(void);
 
 int tattrset(int);
-void tnew(int, int);
+void tnew(int, int, unsigned int);
 void tresize(int, int);
 void tsetdirt(int, int);
 void tsetdirtattr(int);
diff --git a/x.c b/x.c
index aa8ad35..bf5e531 100644
--- a/x.c
+++ b/x.c
_AT_@ -1428,7 +1428,7 @@ xdrawcursor(void)
 
 	/* draw the new one */
 	if (win.state & WIN_FOCUSED) {
-		switch (win.cursor) {
+		switch (term.cursor) {
 		case 7: /* st extension: snowman */
 			utf8decode("☃", &g.u, UTF_SIZ);
 		case 0: /* Blinking Block */
_AT_@ -1849,7 +1849,6 @@ main(int argc, char *argv[])
 {
 	xw.l = xw.t = 0;
 	xw.isfixed = False;
-	win.cursor = cursorshape;
 
 	ARGBEGIN {
 	case 'a':
_AT_@ -1904,7 +1903,7 @@ run:
 	}
 	setlocale(LC_CTYPE, "");
 	XSetLocaleModifiers("");
-	tnew(MAX(cols, 1), MAX(rows, 1));
+	tnew(MAX(cols, 1), MAX(rows, 1), cursorshape);
 	xinit();
 	selinit();
 	run();
-- 
2.14.1
Received on Sun Sep 24 2017 - 23:11:32 CEST

This archive was generated by hypermail 2.3.0 : Sun Sep 24 2017 - 23:25:12 CEST