diff --git a/src/bin/keyin.c b/src/bin/keyin.c index feb39079..889c3ded 100644 --- a/src/bin/keyin.c +++ b/src/bin/keyin.c @@ -229,7 +229,7 @@ keyin_handle(Termpty *ty, Evas_Event_Key_Down *ev) // (!evas_key_modifier_is_set(ev->modifiers, "Shift"))) ) { - if (_key_try(ty, kp_keyout, ev)) return; + if (_key_try(ty, kps_keyout, ev)) return; } else { @@ -286,3 +286,129 @@ keyin_handle(Termpty *ty, Evas_Event_Key_Down *ev) termpty_write(ty, ev->string, strlen(ev->string)); } } + +typedef struct _Compose Compose; + +struct _Compose +{ + unsigned char c1, c2; + const char *out; + int outlen; +}; + +#define COM(c1, c2, out) {c1, c2, out, sizeof(out) - 1} + +static Compose composes[] = +{ + COM('!', '!', "¡"), + COM('|', 'c', "¢"), + COM('-', 'L', "£"), + COM('o', 'x', "¤"), + COM('Y', '-', "¥"), + COM('|', '|', "¦"), + COM('s', 'o', "§"), + COM('"', '"', "¨"), + COM('O', 'c', "©"), + COM('_', 'a', "ª"), + COM('<', '<', "«"), + COM(',', '-', "¬"), + COM('-', '-', "­"), + COM('O', 'R', "®"), + COM('-', '^', "¯"), + COM('^', '0', "°"), + COM('+', '-', "±"), + COM('^', '2', "²"), + COM('^', '3', "³"), + COM('\'', '\'', "´"), + COM('/', 'u', "µ"), + COM('p', '!', "¶"), + COM('.', '.', "·"), + COM(',', ',', "¸"), + COM('^', '1', "¹"), + COM('_', 'o', "º"), + COM('>', '>', "»"), + COM('1', '4', "¼"), + COM('1', '2', "½"), + COM('3', '4', "¾"), + COM('?', '?', "¿"), + COM('`', 'A', "À"), + COM('\'', 'A', "Á"), + COM('^', 'A', "Â"), + COM('~', 'A', "Ã"), + COM('"', 'A', "Ä"), + COM('*', 'A', "Å"), + COM('A', 'E', "Æ"), + COM(',', 'C', "Ç"), + COM('`', 'E', "È"), + COM('\'', 'E', "É"), + COM('^', 'E', "Ê"), + COM('"', 'E', "Ë"), + COM('`', 'I', "Ì"), + COM('\'', 'I', "Í"), + COM('^', 'I', "Î"), + COM('"', 'I', "Ï"), + COM('-', 'D', "Ð"), + COM('~', 'N', "Ñ"), + COM('`', 'O', "Ò"), + COM('\'', 'O', "Ó"), + COM('^', 'O', "Ô"), + COM('~', 'O', "Õ"), + COM('"', 'O', "Ö"), + COM('x', 'x', "×"), + COM('/', 'O', "Ø"), + COM('`', 'U', "Ù"), + COM('\'', 'U', "Ú"), + COM('^', 'U', "Û"), + COM('"', 'U', "Ü"), + COM('\'', 'Y', "Ý"), + COM('T', 'H', "þ"), + COM('s', 's', "ß"), + COM('`', 'a', "à"), + COM('\'', 'a', "á"), + COM('^', 'a', "â"), + COM('~', 'a', "ã"), + COM('"', 'a', "ä"), + COM('*', 'a', "å"), + COM('a', 'e', "æ"), + COM(',', 'c', "ç"), + COM('`', 'e', "è"), + COM('\'', 'e', "é"), + COM('^', 'e', "ê"), + COM('"', 'e', "ë"), + COM('`', 'i', "ì"), + COM('\'', 'i', "í"), + COM('^', 'i', "î"), + COM('"', 'i', "ï"), + COM('-', 'd', "ð"), + COM('~', 'n', "ñ"), + COM('`', 'o', "ò"), + COM('\'', 'o', "ó"), + COM('^', 'o', "ô"), + COM('~', 'o', "õ"), + COM('"', 'o', "ö"), + COM('-', ':', "÷"), + COM('/', 'o', "ø"), + COM('`', 'u', "ù"), + COM('\'', 'u', "ú"), + COM('^', 'u', "û"), + COM('"', 'u', "ü"), + COM('\'', 'y', "ý"), + COM('t', 'h', "þ"), + COM('"', 'y', "ÿ"), + COM(0, 0, "END") +}; + +void +keyin_handle_compose(Termpty *ty, unsigned char c1, unsigned char c2) +{ + int i; + + for (i = 0; composes[i].c1; i++) + { + if ((c1 == composes[i].c1) && (c2 == composes[i].c2)) + { + termpty_write(ty, composes[i].out, composes[i].outlen); + break; + } + } +} diff --git a/src/bin/keyin.h b/src/bin/keyin.h index 10174ca5..08ae85a7 100644 --- a/src/bin/keyin.h +++ b/src/bin/keyin.h @@ -1,2 +1,2 @@ void keyin_handle(Termpty *ty, Evas_Event_Key_Down *ev); - +void keyin_handle_compose(Termpty *ty, unsigned char c1, unsigned char c2); diff --git a/src/bin/termio.c b/src/bin/termio.c index aba01902..7565ec72 100644 --- a/src/bin/termio.c +++ b/src/bin/termio.c @@ -41,6 +41,7 @@ struct _Termio } backup; int scroll; unsigned int last_keyup; + unsigned char compose[2]; Evas_Object *event; Termpty *pty; Ecore_Animator *anim; @@ -51,6 +52,7 @@ struct _Termio Eina_Bool jump_on_change : 1; Eina_Bool have_sel : 1; Eina_Bool noreqsize : 1; + Eina_Bool composing : 1; }; static Evas_Smart *_smart = NULL; @@ -476,6 +478,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, if (by < 1) by = 1; if (!strcmp(ev->keyname, "Prior")) { + sd->composing = EINA_FALSE; sd->scroll += by; if (sd->scroll > sd->pty->backscroll_num) sd->scroll = sd->pty->backscroll_num; @@ -484,6 +487,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, } else if (!strcmp(ev->keyname, "Next")) { + sd->composing = EINA_FALSE; sd->scroll -= by; if (sd->scroll < 0) sd->scroll = 0; _smart_update_queue(data, sd); @@ -491,6 +495,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, } else if (!strcmp(ev->keyname, "Insert")) { + sd->composing = EINA_FALSE; _paste_selection(data, ELM_SEL_TYPE_CLIPBOARD); goto end; } @@ -498,6 +503,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, { Config *config = termio_config_get(data); + sd->composing = EINA_FALSE; if (config) { Evas_Coord mw = 1, mh = 1; @@ -521,6 +527,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, { Config *config = termio_config_get(data); + sd->composing = EINA_FALSE; if (config) { Evas_Coord mw = 1, mh = 1; @@ -544,6 +551,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, { Config *config = termio_config_get(data); + sd->composing = EINA_FALSE; if (config) { Evas_Coord mw = 1, mh = 1; @@ -565,6 +573,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, } else if (!strcmp(ev->keyname, "KP_Divide")) { + sd->composing = EINA_FALSE; _take_selection(data, ELM_SEL_TYPE_CLIPBOARD); goto end; } @@ -576,6 +585,34 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, // timestamp as last one if ((sd->pty->state.no_autorepeat) && (ev->timestamp == sd->last_keyup)) return; + if (!strcmp(ev->keyname, "Multi_key")) + { + sd->composing = EINA_TRUE; + sd->compose[0] = 0; + sd->compose[1] = 0; + return; + } + if (sd->composing) + { + if (ev->string) + { + if (!sd->compose[0]) + { + sd->compose[0] = ev->string[0]; + return; + } + else if (!ev->compose[1]) + { + sd->compose[1] = ev->string[0]; + keyin_handle_compose(sd->pty, + sd->compose[0], sd->compose[1]); + sd->composing = EINA_FALSE; + goto end; + } + } + else + return; + } keyin_handle(sd->pty, ev); end: if (sd->config->flicker_on_key)