use new ecore-input compose handling in terminology.

SVN revision: 72983
This commit is contained in:
Carsten Haitzler 2012-06-28 08:21:51 +00:00
parent 10c9a30898
commit c320a5a230
6 changed files with 35 additions and 10137 deletions

View File

@ -26,6 +26,7 @@ requirements="\
ecore >= 1.2.99 \
edje >= 1.2.99 \
emotion >= 1.0.99 \
ecore-input >= 1.2.99 \
ecore-imf >= 1.2.99 \
ecore-imf-evas >= 1.2.99 \
"

View File

@ -13,7 +13,7 @@ private.h \
col.c col.h \
config.c config.h \
controls.c controls.h \
keyin.c keyin.h keycomp.h \
keyin.c keyin.h \
main.c main.h \
media.c media.h \
options.c options.h \

File diff suppressed because it is too large Load Diff

View File

@ -284,175 +284,3 @@ keyin_handle(Termpty *ty, Evas_Event_Key_Down *ev)
termpty_write(ty, ev->string, strlen(ev->string));
}
}
// http://en.wikipedia.org/wiki/Compose_key
// http://andrew.triumf.ca/iso8859-1-compose.html
// http://cgit.freedesktop.org/xorg/lib/libX11/plain/nls/en_US.UTF-8/Compose.pre
// isolate compose tree into its own file
#include "keycomp.h"
int
keyin_handle_compose(Termpty *ty, char **seq)
{
Comp *c, *cend;
const char *s;
int i = 0;
s = seq[i];
cend = (Comp *)comp + (sizeof(comp) / sizeof(comp[0]));
for (c = (Comp *)comp; c->s && s;)
{
// doesn't match -> jump to next level entry
if (!(!strcmp(s, c->s)))
{
c += c->jump + 1;
if (c >= cend) return 0;
}
else
{
cend = c + c->jump;
// advance to next sequence member
i++;
s = seq[i];
c++;
// if advanced item jump is an endpoint - it's the string we want
if (c->jump == 0)
{
termpty_write(ty, c->s, strlen(c->s));
return -1;
}
}
}
if (i > 0) return 1;
return 0;
}
/*
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;
}
}
}
*/

View File

@ -1,3 +1 @@
void keyin_handle(Termpty *ty, Evas_Event_Key_Down *ev);
int keyin_handle_compose(Termpty *ty, char **seq);
//void keyin_handle_compose(Termpty *ty, unsigned char c1, unsigned char c2);

View File

@ -2,6 +2,7 @@
#include <Ecore_IMF.h>
#include <Ecore_IMF_Evas.h>
#include <Elementary.h>
#include <Ecore_Input.h>
#include "termio.h"
#include "termpty.h"
#include "utf8.h"
@ -41,7 +42,7 @@ struct _Termio
} backup;
int scroll;
unsigned int last_keyup;
char *compose[10]; // max 10 chars
Eina_List *seq;
Evas_Object *event;
Termpty *pty;
Ecore_Animator *anim;
@ -452,6 +453,8 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
{
Evas_Event_Key_Down *ev = event;
Termio *sd;
Ecore_Compose_State state;
char *compres = NULL, *str;
sd = evas_object_smart_data_get(data);
if (!sd) return;
@ -481,6 +484,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
if (by < 1) by = 1;
if (!strcmp(ev->keyname, "Prior"))
{
EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
sd->composing = EINA_FALSE;
sd->scroll += by;
if (sd->scroll > sd->pty->backscroll_num)
@ -490,6 +494,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
}
else if (!strcmp(ev->keyname, "Next"))
{
EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
sd->composing = EINA_FALSE;
sd->scroll -= by;
if (sd->scroll < 0) sd->scroll = 0;
@ -498,6 +503,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
}
else if (!strcmp(ev->keyname, "Insert"))
{
EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
sd->composing = EINA_FALSE;
_paste_selection(data, ELM_SEL_TYPE_CLIPBOARD);
goto end;
@ -506,6 +512,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
{
Config *config = termio_config_get(data);
EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
sd->composing = EINA_FALSE;
if (config)
{
@ -530,6 +537,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
{
Config *config = termio_config_get(data);
EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
sd->composing = EINA_FALSE;
if (config)
{
@ -554,6 +562,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
{
Config *config = termio_config_get(data);
EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
sd->composing = EINA_FALSE;
if (config)
{
@ -576,6 +585,7 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
}
else if (!strcmp(ev->keyname, "KP_Divide"))
{
EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
sd->composing = EINA_FALSE;
_take_selection(data, ELM_SEL_TYPE_CLIPBOARD);
goto end;
@ -590,78 +600,42 @@ _smart_cb_key_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__,
(ev->timestamp == sd->last_keyup)) return;
if (!sd->composing)
{
int i;
for (i = 0; i < 10; i++)
{
if (sd->compose[i])
{
free(sd->compose[i]);
sd->compose[i] = NULL;
}
else break;
}
sd->compose[0] = strdup(ev->key);
sd->compose[1] = NULL;
if (keyin_handle_compose(sd->pty, sd->compose))
sd->composing = EINA_TRUE;
EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
sd->seq = eina_list_append(sd->seq, eina_stringshare_add(ev->key));
state = ecore_compose_get(sd->seq, &compres);
if (state == ECORE_COMPOSE_MIDDLE) sd->composing = EINA_TRUE;
else sd->composing = EINA_FALSE;
if (!sd->composing)
{
free(sd->compose[0]);
sd->compose[0] = NULL;
}
else
{
goto end;
EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
}
else goto end;
}
else
{
int status, i;
if (!strncmp(ev->key, "Shift", 5)) goto end;
if (!strncmp(ev->key, "Control", 7)) goto end;
if (!strncmp(ev->key, "Alt", 3)) goto end;
// if (!ev->string) goto end;
for (i = 0; i < 10; i++)
sd->seq = eina_list_append(sd->seq, eina_stringshare_add(ev->key));
state = ecore_compose_get(sd->seq, &compres);
if (state == ECORE_COMPOSE_NONE)
{
if (!sd->compose[i])
{
sd->compose[i] = strdup(ev->key);
sd->compose[i + 1] = NULL;
break;
}
EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
sd->composing = EINA_FALSE;
}
status = keyin_handle_compose(sd->pty, sd->compose);
if (status == 0)
else if (state == ECORE_COMPOSE_DONE)
{
for (i = 0; i < 10; i++)
EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
sd->composing = EINA_FALSE;
if (compres)
{
if (sd->compose[i])
{
free(sd->compose[i]);
sd->compose[i] = NULL;
}
else break;
termpty_write(sd->pty, compres, strlen(compres));
free(compres);
compres = NULL;
}
sd->composing = 0;
}
else if (status == -1)
{
for (i = 0; i < 10; i++)
{
if (sd->compose[i])
{
free(sd->compose[i]);
sd->compose[i] = NULL;
}
else break;
}
sd->composing = 0;
goto end;
}
else
goto end;
else goto end;
}
keyin_handle(sd->pty, ev);
end:
@ -1451,7 +1425,7 @@ imf_done:
static void
_smart_del(Evas_Object *obj)
{
int i;
char *str;
Termio *sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (sd->imf)
@ -1469,15 +1443,7 @@ _smart_del(Evas_Object *obj)
if (sd->delayed_size_timer) ecore_timer_del(sd->delayed_size_timer);
if (sd->font.name) eina_stringshare_del(sd->font.name);
if (sd->pty) termpty_free(sd->pty);
for (i = 0; i < 10; i++)
{
if (sd->compose[i])
{
free(sd->compose[i]);
sd->compose[i] = NULL;
}
else break;
}
EINA_LIST_FREE(sd->seq, str) eina_stringshare_del(str);
sd->cur.obj = NULL;
sd->event = NULL;
sd->cur.selo1 = NULL;