From 0dd8951cb3d3b260575162ebbd1914c61a10d876 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 21 Jul 2019 19:14:19 +0200 Subject: 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. --- csi.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'csi.c') diff --git a/csi.c b/csi.c index 12579c27..4d40686d 100644 --- a/csi.c +++ b/csi.c @@ -5,6 +5,8 @@ #include #include +#include + #if defined(_DEBUG) #include #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; -- cgit v1.3