mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-21 01:40:16 -05:00
csi: xtsave/xtrestore: implement \E[?12s and \E[?12r
I.e. save/restore cursor-blink state.
This commit is contained in:
parent
15ae82e62e
commit
22dcbeacb7
2 changed files with 19 additions and 3 deletions
20
csi.c
20
csi.c
|
|
@ -4,11 +4,14 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <sys/timerfd.h>
|
||||||
|
|
||||||
#define LOG_MODULE "csi"
|
#define LOG_MODULE "csi"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
@ -552,7 +555,20 @@ xtsave(struct terminal *term, unsigned param)
|
||||||
case 6: term->xtsave.origin = term->origin; break;
|
case 6: term->xtsave.origin = term->origin; break;
|
||||||
case 7: term->xtsave.auto_margin = term->auto_margin; break;
|
case 7: term->xtsave.auto_margin = term->auto_margin; break;
|
||||||
case 9: /* term->xtsave.mouse_x10 = term->mouse_tracking == MOUSE_X10; */ 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, ¤t_value) < 0)
|
||||||
|
LOG_WARN("xtsave: failed to read cursor blink timer: %s", strerror(errno));
|
||||||
|
else {
|
||||||
|
const struct timespec zero = {};
|
||||||
|
term->xtsave.cursor_blink =
|
||||||
|
!(memcmp(¤t_value.it_interval, &zero, sizeof(zero)) == 0 &&
|
||||||
|
memcmp(¤t_value.it_value, &zero, sizeof(zero)) == 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 25: term->xtsave.show_cursor = !term->hide_cursor; break;
|
case 25: term->xtsave.show_cursor = !term->hide_cursor; break;
|
||||||
case 1000: term->xtsave.mouse_click = term->mouse_tracking == MOUSE_CLICK; break;
|
case 1000: term->xtsave.mouse_click = term->mouse_tracking == MOUSE_CLICK; break;
|
||||||
case 1001: break;
|
case 1001: break;
|
||||||
|
|
@ -582,7 +598,7 @@ xtrestore(struct terminal *term, unsigned param)
|
||||||
case 6: enable = term->xtsave.origin; break;
|
case 6: enable = term->xtsave.origin; break;
|
||||||
case 7: enable = term->xtsave.auto_margin; break;
|
case 7: enable = term->xtsave.auto_margin; break;
|
||||||
case 9: /* enable = term->xtsave.mouse_x10; break; */ return;
|
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 25: enable = term->xtsave.show_cursor; break;
|
||||||
case 1000: enable = term->xtsave.mouse_click; break;
|
case 1000: enable = term->xtsave.mouse_click; break;
|
||||||
case 1001: return;
|
case 1001: return;
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ struct terminal {
|
||||||
uint32_t reverse:1;
|
uint32_t reverse:1;
|
||||||
uint32_t show_cursor:1;
|
uint32_t show_cursor:1;
|
||||||
uint32_t auto_margin:1;
|
uint32_t auto_margin:1;
|
||||||
//uint32_t cursor_blink:1;
|
uint32_t cursor_blink:1;
|
||||||
uint32_t insert_mode:1;
|
uint32_t insert_mode:1;
|
||||||
uint32_t bracketed_paste:1;
|
uint32_t bracketed_paste:1;
|
||||||
uint32_t focus_events:1;
|
uint32_t focus_events:1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue