mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-23 05:33:57 -04:00
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:
parent
1ff04c5e36
commit
0dd8951cb3
5 changed files with 84 additions and 22 deletions
19
csi.c
19
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue