aboutsummaryrefslogtreecommitdiff
path: root/csi.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-21 17:14:19 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-21 17:14:19 +0000
commit0dd8951cb3d3b260575162ebbd1914c61a10d876 (patch)
treee05b6e5584516e97a285780c9fec8e114a2123fc /csi.c
parentcsi: remove erronous final (diff)
flash: implement 'flash'
Use our own escape sequence for the 'flash' terminfo entry. Implemented by arming a timer FD and setting a boolean that indicates we're currently "flashing". The renderer draws a semi-transparent yellowish layer over the entire window when "flashing" is active.
Diffstat (limited to 'csi.c')
-rw-r--r--csi.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/csi.c b/csi.c
index 12579c27..4d40686d 100644
--- a/csi.c
+++ b/csi.c
@@ -5,6 +5,8 @@
#include <unistd.h>
#include <assert.h>
+#include <sys/timerfd.h>
+
#if defined(_DEBUG)
#include <stdio.h>
#endif
@@ -573,6 +575,23 @@ csi_dispatch(struct terminal *term, uint8_t final)
break;
}
+ case 1001: {
+ /* Our own private - flash */
+ unsigned duration_ms = vt_param_get(term, 1, 100);
+ LOG_WARN("FLASH for %ums", duration_ms);
+
+ struct itimerspec alarm = {
+ .it_value = {.tv_sec = 0, .tv_nsec = duration_ms * 1000000},
+ };
+
+ if (timerfd_settime(term->flash_timer_fd, 0, &alarm, NULL) < 0)
+ LOG_ERRNO("failed to arm flash timer");
+ else {
+ term->flash_active = true;
+ }
+ break;
+ }
+
default:
LOG_WARN("ignoring %s", csi_as_string(term, final));
break;