From 61409d40e290e8eff75fe567942b4ba5438d23a0 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 22 Jul 2019 19:10:15 +0200 Subject: flash: convert our own 'flash' from a CSI to an OSC --- osc.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'osc.c') diff --git a/osc.c b/osc.c index 9ec73ac2..2845ab96 100644 --- a/osc.c +++ b/osc.c @@ -3,6 +3,8 @@ #include #include +#include + #define LOG_MODULE "osc" #define LOG_ENABLE_DBG 0 #include "log.h" @@ -200,6 +202,24 @@ osc_selection(struct terminal *term, char *string) osc_to_clipboard(term, string, p); } +static void +osc_flash(struct terminal *term) +{ + /* Our own private - flash */ + unsigned duration_ms = vt_param_get(term, 1, 100); + LOG_DBG("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; + } +} + void osc_dispatch(struct terminal *term) { @@ -244,6 +264,10 @@ osc_dispatch(struct terminal *term) case 112: /* Reset text cursor color */ break; + case 555: + osc_flash(term); + break; + default: LOG_ERR("unimplemented: OSC: %.*s", (int)term->vt.osc.idx, term->vt.osc.data); -- cgit v1.3