2
3
4
5
6
7
17
18
20
21
22
23static UiKey translate_key(
int ch) {
93 if (ch >= 32 && ch <= 126)
100
101
103 if (
ui &&
ui->tty_fd >= 0) {
104 tcflush(
ui->tty_fd, TCIFLUSH);
109
110
111
112
113
114
115
116int ui_get_event(UiSurface *s, ss_t w, UiChyron *chyron, UiEvent *ev,
int timeout_ms) {
124 if (timeout_ms > 0) {
131 memset(fds, 0,
sizeof(fds));
132 fds[0].fd =
ui->tty_fd;
133 fds[0].events = POLLIN;
135 nfds_t ext_start_idx = nfds;
138 fds[nfds].events = POLLIN;
141 int poll_rc = poll(fds, nfds, timeout_ms);
151 bool ui_ready = (fds[0].revents & POLLIN);
153 for (nfds_t i = ext_start_idx; i < nfds; i++) {
154 if (fds[i].revents & (POLLIN | POLLHUP | POLLERR)) {
155 reg_idx = i - ext_start_idx;
163 memset(ev, 0,
sizeof(*ev));
164 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);
165 wtimeout(s->mwin[w], timeout_ms);
168 ch = wgetch(s->mwin[w]);
172 if (ch ==
'q' || ch ==
'Q' || ch ==
UIKEY_F09)
177 if (timeout_ms > 0 && ch ==
ERR) {
183 ev
->key = translate_key(ch);
185 ev
->ch = (uint32_t)ch;
188 if (getmouse(&me) != OK) {
202 if (s->mwin[i] != NULL &&
203 wenclose(s->mwin[i], me.y, me.x) &&
204 wmouse_trafo(s->mwin[i], &me.y, &me.x,
false)) {
216 if (ev
->in_win == chyron->w && ev
->y == chyron->y) {
228
229
230
231
232
233
242 ch = wgetch(s->mwin[w]);
244 ev
->key = translate_key(ch);
246 ev
->ch = (uint32_t)ch;
255
256
258
259
260
265 mousemask(mask,
nullptr);
267 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION,
nullptr);
271
272
273
278 mousemask(mask,
nullptr);
280 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION,
nullptr);
volatile sig_atomic_t sig_received
bool handle_signal(sig_atomic_t)
void ui_render()
Render the UI by updating panels and refreshing the display.
int ui_mice_enable(int mask)
Enable or disable mouse support.
int ui_get_event_no_mouse(UiSurface *surface, ss_t w, UiEvent *ev)
Wait for an input event on target (or stdscr if NULL) without mouse support.
int ui_mousemask(int mask)
Enable or disable mouse support.
#define UIKEY_BUTTON4_PRESSED
#define UIKEY_BUTTON5_PRESSED
#define UIKEY_BUTTON1_CLICKED
#define UIKEY_SCROLL_DOWN
void ui_flush_input()
Flush any pending input events from the NotCurses context. This function discards any input events th...
int ui_get_event(UiSurface *s, ss_t w, UiChyron *chyron, UiEvent *ev, int timeout_ms)
Read input events.
int ui_get_chyron_key(UiChyron *chyron, uint x)
Get keycode from chyron.
int ui_display_error(char *msg0, char *msg1, char *msg2, char *msg3)
Display an error message window or print to stderr.
UiMouseAction mouse_action
ext_fd_reg_t ext_fds[MAX_EXT_FDS]