commit a31a447

uint  ·  2026-05-14 18:17:02 +0000 UTC
parent efaab74
add terminal cursor visibility toggle
3 files changed,  +6, -1
+3, -1
 1@@ -50,6 +50,7 @@ static Term term = {
 2 	.ptypid = -1,
 3 	.fg = TERM_DEFAULT_FG,
 4 	.bg = TERM_DEFAULT_BG,
 5+	.cursor_visible = true,
 6 };
 7 
 8 /**
 9@@ -347,7 +348,8 @@ static void run(void)
10 		for (int y = 0; y < term.rows; y++) {
11 			for (int x = 0; x < term.cols; x++) {
12 				Rune* r = &RUNE(&term, x, y);
13-				bool cursor = x == car.x && y == car.y;
14+				bool cursor = term.cursor_visible &&
15+				              x == car.x && y == car.y;
16 				uint32_t fg = cursor ? r->bg : r->fg;
17 				uint32_t bg = cursor ? r->fg : r->bg;
18 
+1, -0
1@@ -46,6 +46,7 @@ typedef struct {
2 
3 	enum TState    state;
4 	bool           wrapnext;
5+	bool           cursor_visible;
6 	int            csi_params[CSI_PARAMS_MAX];
7 	int            csi_idx;
8 	char           utf8[4];
+2, -0
1@@ -198,6 +198,8 @@ static void csi_dispatch(Term* t, Caret* c, unsigned char ch)
2 		bool on = ch == 'h';
3 		for (int i = 0; i <= t->csi_idx; i++) {
4 			int p = t->csi_params[i];
5+			if (p == 25)
6+				t->cursor_visible = on;
7 			if (p == 1048) {
8 				if (on)
9 					t->saved = *c;