aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-08-18 05:00:26 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-08-18 05:00:26 +0000
commit22dcbeacb702fd3600a4644996f1420cd778db3a (patch)
tree067766d8a733194172ac6abef2fde0398df8e91d
parentcsi: decset/decrst: only clear mouse tracking/reporting if mode matches (diff)
csi: xtsave/xtrestore: implement \E[?12s and \E[?12r
I.e. save/restore cursor-blink state.
-rw-r--r--csi.c20
-rw-r--r--terminal.h2
2 files changed, 19 insertions, 3 deletions
diff --git a/csi.c b/csi.c
index fe5460e3..9c998cb4 100644
--- a/csi.c
+++ b/csi.c
@@ -4,11 +4,14 @@
#include <string.h>
#include <unistd.h>
#include <assert.h>
+#include <errno.h>
#if defined(_DEBUG)
#include <stdio.h>
#endif
+#include <sys/timerfd.h>
+
#define LOG_MODULE "csi"
#define LOG_ENABLE_DBG 0
#include "log.h"
@@ -552,7 +555,20 @@ xtsave(struct terminal *term, unsigned param)
case 6: term->xtsave.origin = term->origin; break;
case 7: term->xtsave.auto_margin = term->auto_margin; break;
case 9: /* term->xtsave.mouse_x10 = term->mouse_tracking == MOUSE_X10; */ break;
- case 12: break;
+
+ case 12: {
+ struct itimerspec current_value;
+ if (timerfd_gettime(term->cursor_blink.fd, &current_value) < 0)
+ LOG_WARN("xtsave: failed to read cursor blink timer: %s", strerror(errno));
+ else {
+ const struct timespec zero = {};
+ term->xtsave.cursor_blink =
+ !(memcmp(&current_value.it_interval, &zero, sizeof(zero)) == 0 &&
+ memcmp(&current_value.it_value, &zero, sizeof(zero)) == 0);
+ }
+ break;
+ }
+
case 25: term->xtsave.show_cursor = !term->hide_cursor; break;
case 1000: term->xtsave.mouse_click = term->mouse_tracking == MOUSE_CLICK; break;
case 1001: break;
@@ -582,7 +598,7 @@ xtrestore(struct terminal *term, unsigned param)
case 6: enable = term->xtsave.origin; break;
case 7: enable = term->xtsave.auto_margin; break;
case 9: /* enable = term->xtsave.mouse_x10; break; */ return;
- case 12: return;
+ case 12: enable = term->xtsave.cursor_blink; break;
case 25: enable = term->xtsave.show_cursor; break;
case 1000: enable = term->xtsave.mouse_click; break;
case 1001: return;
diff --git a/terminal.h b/terminal.h
index 86b5e80b..d1235c2f 100644
--- a/terminal.h
+++ b/terminal.h
@@ -253,7 +253,7 @@ struct terminal {
uint32_t reverse:1;
uint32_t show_cursor:1;
uint32_t auto_margin:1;
- //uint32_t cursor_blink:1;
+ uint32_t cursor_blink:1;
uint32_t insert_mode:1;
uint32_t bracketed_paste:1;
uint32_t focus_events:1;