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.
This commit is contained in:
Daniel Eklöf 2019-07-21 19:14:19 +02:00
parent 1ff04c5e36
commit 0dd8951cb3
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 84 additions and 22 deletions

19
csi.c
View file

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