mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-06 07:15:30 -04:00
term: break out 'flash' to a separate 'term' function
This commit is contained in:
parent
89f1b3ae73
commit
e3dc184882
3 changed files with 19 additions and 13 deletions
14
osc.c
14
osc.c
|
|
@ -3,8 +3,6 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <sys/timerfd.h>
|
|
||||||
|
|
||||||
#define LOG_MODULE "osc"
|
#define LOG_MODULE "osc"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
@ -205,17 +203,7 @@ osc_flash(struct terminal *term)
|
||||||
{
|
{
|
||||||
/* Our own private - flash */
|
/* Our own private - flash */
|
||||||
unsigned duration_ms = vt_param_get(term, 1, 100);
|
unsigned duration_ms = vt_param_get(term, 1, 100);
|
||||||
LOG_DBG("FLASH for %ums", duration_ms);
|
term_flash(term, duration_ms);
|
||||||
|
|
||||||
struct itimerspec alarm = {
|
|
||||||
.it_value = {.tv_sec = 0, .tv_nsec = duration_ms * 1000000},
|
|
||||||
};
|
|
||||||
|
|
||||||
if (timerfd_settime(term->flash.fd, 0, &alarm, NULL) < 0)
|
|
||||||
LOG_ERRNO("failed to arm flash timer");
|
|
||||||
else {
|
|
||||||
term->flash.active = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
17
terminal.c
17
terminal.c
|
|
@ -4,6 +4,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <sys/timerfd.h>
|
||||||
#include <linux/input-event-codes.h>
|
#include <linux/input-event-codes.h>
|
||||||
|
|
||||||
#define LOG_MODULE "terminal"
|
#define LOG_MODULE "terminal"
|
||||||
|
|
@ -485,3 +486,19 @@ term_set_window_title(struct terminal *term, const char *title)
|
||||||
term->window_title = strdup(title);
|
term->window_title = strdup(title);
|
||||||
render_set_title(term, term->window_title);
|
render_set_title(term, term->window_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
term_flash(struct terminal *term, unsigned duration_ms)
|
||||||
|
{
|
||||||
|
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.fd, 0, &alarm, NULL) < 0)
|
||||||
|
LOG_ERRNO("failed to arm flash timer");
|
||||||
|
else {
|
||||||
|
term->flash.active = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -382,3 +382,4 @@ void term_mouse_motion(struct terminal *term, int button, int row, int col,
|
||||||
bool shift, bool alt, bool ctrl);
|
bool shift, bool alt, bool ctrl);
|
||||||
|
|
||||||
void term_set_window_title(struct terminal *term, const char *title);
|
void term_set_window_title(struct terminal *term, const char *title);
|
||||||
|
void term_flash(struct terminal *term, unsigned duration_ms);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue