csi: xtsave/xtrestore: implement \E[?12s and \E[?12r

I.e. save/restore cursor-blink state.
This commit is contained in:
Daniel Eklöf 2020-08-18 07:00:26 +02:00
parent 15ae82e62e
commit 22dcbeacb7
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 19 additions and 3 deletions

20
csi.c
View file

@ -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;

View file

@ -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;