summaryrefslogtreecommitdiff
path: root/src/bin/keyin.c
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2018-02-05 00:07:47 +0100
committerBoris Faure <billiob@gmail.com>2018-02-05 00:07:47 +0100
commitd7432a52d6a38bc5d8fbb47b58bfa3fd41cd0d3f (patch)
tree2e01ae1b0a4824d5b8b3afd59310e825abbdf4d4 /src/bin/keyin.c
parente5c580aa267dde164a6d7b1ef3c9e9a1d80dcf8c (diff)
move input handling to win.c
Diffstat (limited to 'src/bin/keyin.c')
-rw-r--r--src/bin/keyin.c84
1 files changed, 8 insertions, 76 deletions
diff --git a/src/bin/keyin.c b/src/bin/keyin.c
index 78601af..c5bc7f2 100644
--- a/src/bin/keyin.c
+++ b/src/bin/keyin.c
@@ -102,9 +102,9 @@ keyin_compose_seq_reset(Keys_Handler *khdl)
102 102
103#include "tty_keys.h" 103#include "tty_keys.h"
104 104
105static void 105void
106_handle_key_to_pty(Termpty *ty, const Evas_Event_Key_Down *ev, 106keyin_handle_key_to_pty(Termpty *ty, const Evas_Event_Key_Down *ev,
107 int alt, int shift, int ctrl) 107 const int alt, const int shift, const int ctrl)
108{ 108{
109 if (!ev->key) 109 if (!ev->key)
110 return; 110 return;
@@ -228,92 +228,24 @@ key_binding_lookup(const char *keyname,
228} 228}
229 229
230Eina_Bool 230Eina_Bool
231keyin_handle(Keys_Handler *khdl, Termpty *ty, const Evas_Event_Key_Down *ev, 231keyin_handle_key_binding(Evas_Object *termio, const Evas_Event_Key_Down *ev,
232 Eina_Bool ctrl, Eina_Bool alt, Eina_Bool shift, Eina_Bool win, 232 Eina_Bool ctrl, Eina_Bool alt, Eina_Bool shift,
233 Eina_Bool meta, Eina_Bool hyper) 233 Eina_Bool win, Eina_Bool meta, Eina_Bool hyper)
234{ 234{
235 235
236 Key_Binding *kb; 236 Key_Binding *kb;
237 kb = key_binding_lookup(ev->keyname, ctrl, alt, shift, win, meta, hyper); 237 kb = key_binding_lookup(ev->keyname, ctrl, alt, shift, win, meta, hyper);
238 if (kb) 238 if (kb)
239 { 239 {
240 if (kb->cb(ty->obj)) 240 if (kb->cb(termio))
241 { 241 {
242 keyin_compose_seq_reset(khdl);
243 return EINA_TRUE; 242 return EINA_TRUE;
244 } 243 }
245 } 244 }
246
247 /* composing */
248 if (khdl->imf)
249 {
250 // EXCEPTION. Don't filter modifiers alt+shift -> breaks emacs
251 // and jed (alt+shift+5 for search/replace for example)
252 // Don't filter modifiers alt, is used by shells
253 if ((!alt) && (!ctrl))
254 {
255 Ecore_IMF_Event_Key_Down imf_ev;
256
257 ecore_imf_evas_event_key_down_wrap((Evas_Event_Key_Down*)ev, &imf_ev);
258 if (!khdl->composing)
259 {
260 if (ecore_imf_context_filter_event
261 (khdl->imf, ECORE_IMF_EVENT_KEY_DOWN, (Ecore_IMF_Event *)&imf_ev))
262 goto end;
263 }
264 }
265 }
266
267 // if term app asked for kbd lock - dont handle here
268 if (ty->termstate.kbd_lock) return EINA_TRUE;
269 // if app asked us to not do autorepeat - ignore press if is it is the same
270 // timestamp as last one
271 if ((ty->termstate.no_autorepeat) &&
272 (ev->timestamp == khdl->last_keyup)) return EINA_TRUE;
273 if (!khdl->composing)
274 {
275 Ecore_Compose_State state;
276 char *compres = NULL;
277
278 keyin_compose_seq_reset(khdl);
279 khdl->seq = eina_list_append(khdl->seq, eina_stringshare_add(ev->key));
280 state = ecore_compose_get(khdl->seq, &compres);
281 if (state == ECORE_COMPOSE_MIDDLE) khdl->composing = EINA_TRUE;
282 else khdl->composing = EINA_FALSE;
283 if (!khdl->composing) keyin_compose_seq_reset(khdl);
284 else goto end;
285 }
286 else
287 {
288 Ecore_Compose_State state;
289 char *compres = NULL;
290
291 if (key_is_modifier(ev->key)) goto end;
292 khdl->seq = eina_list_append(khdl->seq, eina_stringshare_add(ev->key));
293 state = ecore_compose_get(khdl->seq, &compres);
294 if (state == ECORE_COMPOSE_NONE) keyin_compose_seq_reset(khdl);
295 else if (state == ECORE_COMPOSE_DONE)
296 {
297 keyin_compose_seq_reset(khdl);
298 if (compres)
299 {
300 termpty_write(ty, compres, strlen(compres));
301 free(compres);
302 compres = NULL;
303 }
304 goto end;
305 }
306 else goto end;
307 }
308
309
310 _handle_key_to_pty(ty, ev, alt, shift, ctrl);
311
312
313end:
314 return EINA_FALSE; 245 return EINA_FALSE;
315} 246}
316 247
248
317Eina_Bool 249Eina_Bool
318key_is_modifier(const char *key) 250key_is_modifier(const char *key)
319{ 251{