summaryrefslogtreecommitdiff
path: root/src/lib/ecore_input/ecore_input_compose.c
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-12-02 22:35:45 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-12-02 22:35:45 +0000
commit7d6010b12c47a20e492da808e3192c3f87dab619 (patch)
tree26c6fd189e046a76560c0bc740b85f4d767ae399 /src/lib/ecore_input/ecore_input_compose.c
parent53fc441d5475155965d92da89502fe4634a561b2 (diff)
merge: add escape ecore, fix several bugs
SVN revision: 79995
Diffstat (limited to 'src/lib/ecore_input/ecore_input_compose.c')
-rw-r--r--src/lib/ecore_input/ecore_input_compose.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/lib/ecore_input/ecore_input_compose.c b/src/lib/ecore_input/ecore_input_compose.c
new file mode 100644
index 0000000000..5335a7fe0c
--- /dev/null
+++ b/src/lib/ecore_input/ecore_input_compose.c
@@ -0,0 +1,61 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdio.h>
6#include <string.h>
7
8#include "Ecore.h"
9#include "ecore_private.h"
10
11#include "Ecore_Input.h"
12#include "ecore_input_private.h"
13
14// some info on a big big big compose table
15// http://cgit.freedesktop.org/xorg/lib/libX11/plain/nls/en_US.UTF-8/Compose.pre
16// isolate compose tree into its own file - hand crafted into static const c
17#include "ecore_input_compose.h"
18
19EAPI Ecore_Compose_State
20ecore_compose_get(const Eina_List *seq, char **seqstr_ret)
21{
22 Comp *c, *cend;
23 Eina_List *l;
24 const char *s;
25 int i = 0;
26
27 if (!seq) return ECORE_COMPOSE_NONE;
28 l = (Eina_List *)seq;
29 s = l->data;
30 cend = (Comp *)comp + (sizeof(comp) / sizeof(comp[0]));
31 for (c = (Comp *)comp; c->s && s;)
32 {
33 // doesn't match -> jump to next level entry
34 if (!(!strcmp(s, c->s)))
35 {
36 c += c->jump + 1;
37 if (c >= cend)
38 {
39 return ECORE_COMPOSE_NONE;
40 }
41 }
42 else
43 {
44 cend = c + c->jump;
45 // advance to next sequence member
46 l = l->next;
47 i++;
48 if (l) s = l->data;
49 else s = NULL;
50 c++;
51 // if advanced item jump is an endpoint - it's the string we want
52 if (c->jump == 0)
53 {
54 if (seqstr_ret) *seqstr_ret = strdup(c->s);
55 return ECORE_COMPOSE_DONE;
56 }
57 }
58 }
59 if (i == 0) return ECORE_COMPOSE_NONE;
60 return ECORE_COMPOSE_MIDDLE;
61}