2
3
4
5
6
7
15
16
18static UiKey translate_key(
int ch) {
86 if (ch >= 32 && ch <= 126)
93
94
97
98
99
100
101
102
106 memset(ev, 0,
sizeof(*ev));
107 tcflush(2, TCIFLUSH);
108 if (timeout_ms <= 0) {
111 wtimeout(s->mwin[w], timeout_ms);
112 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION | BUTTON_SHIFT | BUTTON_CTRL | BUTTON_ALT, NULL);
114 int ch = wgetch(s->mwin[w]);
116 ev
->key = translate_key(ch);
118 ev
->ch = (uint32_t)ch;
121 if (getmouse(&me) == OK) {
124 if (me.bstate & BUTTON4_PRESSED)
126 else if (me.bstate & BUTTON5_PRESSED)
128 else if (me.bstate & BUTTON1_PRESSED)
130 else if (me.bstate & BUTTON1_RELEASED)
132 if (wenclose(s->mwin[w], me.y, me.x) &&
133 wmouse_trafo(s->mwin[w], &me.y, &me.x,
false)) {
150 memset(ev, 0,
sizeof(*ev));
151 keypad(s->mwin[w],
true);
152 if (timeout_ms <= 0) {
155 wtimeout(s->mwin[w], timeout_ms);
156 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION | BUTTON_SHIFT | BUTTON_CTRL | BUTTON_ALT, NULL);
159 tcflush(2, TCIFLUSH);
162 int ch = wgetch(s->mwin[w]);
165 ev
->key = translate_key(ch);
167 ev
->ch = (uint32_t)ch;
170 if (getmouse(&me) == OK) {
173 if (me.bstate & BUTTON4_PRESSED)
175 else if (me.bstate & BUTTON5_PRESSED)
177 else if (me.bstate & BUTTON1_CLICKED ||
178 me.bstate & BUTTON1_PRESSED ||
179 me.bstate & BUTTON1_DOUBLE_CLICKED) {
183 if (s->mwin[i] != NULL &&
184 wenclose(s->mwin[i], me.y, me.x) &&
185 wmouse_trafo(s->mwin[i], &me.y, &me.x,
false)) {
208 tcflush(2, TCIFLUSH);
212 ch = wgetch(s->mwin[w]);
214 ev
->key = translate_key(ch);
216 ev
->ch = (uint32_t)ch;
223
224
229 mousemask(mask,
nullptr);
231 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION,
nullptr);
238 mousemask(mask,
nullptr);
240 mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION,
nullptr);
int ui_mice_enable(int mask)
int ui_get_event_no_mouse(UiSurface *surface, uint w, UiEvent *ev)
int ui_get_event(UiSurface *s, uint w, UiEvent *ev, int timeout_ms)
Wait for an input event on target (or stdscr if NULL).
int ui_mousemask(int mask)
int ui_get_event_multi(UiSurface *s, uint w, UiEvent *ev, int timeout_ms)
UiMouseAction mouse_action