Fix license
[platform/core/uifw/anthy.git] / anthy / input.h
1 /*
2  * Some comments are written in Japanese.
3  *
4  * Funded by IPA̤Ƨ¥½¥Õ¥È¥¦¥§¥¢ÁϤ»ö¶È 2001
5  *
6  * Comments are in Japanese(EUC-JP)
7  * doc/ILIB »²¾È
8  */
9
10 #ifndef INPUT_H_INCLUDE
11 #define INPUT_H_INCLUDE
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 struct anthy_input_context;
18
19 extern int anthy_input_errno;
20 #define AIE_NOMEM 1
21 #define AIE_INVAL 2
22 #define AIE_NOIMPL 3
23
24 #define ANTHY_INPUT_ST_OFF  0  /* Ìµ¸ú¾õÂÖ */ /* anthy agent does not use this state */
25 #define ANTHY_INPUT_ST_NONE 1  /* ÂÔµ¡¾õÂÖ */
26 #define ANTHY_INPUT_ST_EDIT 2  /* ÊÔ½¸¾õÂÖ */
27 #define ANTHY_INPUT_ST_CONV 3  /* ÊÑ´¹¾õÂÖ */
28 #define ANTHY_INPUT_ST_CSEG 4  /* Ê¸Àá¿­½Ì¾õÂÖ */
29
30 #define ANTHY_INPUT_MAP_ALPHABET  0
31 #define ANTHY_INPUT_MAP_WALPHABET 1
32 #define ANTHY_INPUT_MAP_HIRAGANA  2
33 #define ANTHY_INPUT_MAP_KATAKANA  3
34 #define ANTHY_INPUT_MAP_HANKAKU_KANA 4
35
36 #define ANTHY_INPUT_SF_NONE         0x00000000
37 #define ANTHY_INPUT_SF_CURSOR       0x00000001
38 #define ANTHY_INPUT_SF_ENUM         0x00000002
39 #define ANTHY_INPUT_SF_ENUM_REVERSE 0x00000004
40 #define ANTHY_INPUT_SF_EDITING      0x00000008
41 #define ANTHY_INPUT_SF_PENDING      0x00000010
42 #define ANTHY_INPUT_SF_FOLLOWING    0x00000020
43   /* This have been in public API!*/
44 #define ANTHY_INPUT_SF_EDITTING     0x00000008
45
46 struct anthy_input_config;
47 struct anthy_input_context;
48
49 /*
50  * anthy_input_get_preedit();
51  * anthy_input_free_preedit();
52  */
53 struct anthy_input_preedit {
54   int state;
55
56   char* commit;
57   char* cut_buf;
58
59   struct anthy_input_segment* segment;
60   struct anthy_input_segment* cur_segment;
61 };
62
63 /*
64  * anthy_input_get_candidate();
65  * anthy_input_free_segment();
66  */
67 struct anthy_input_segment {
68   char* str;
69   int cand_no;
70   int noconv_len;
71   int nr_cand;
72   int flag;
73
74   struct anthy_input_segment* next;
75 };
76
77 /* initialize ... */
78 int anthy_input_init(void);
79
80 /* context management*/
81 void anthy_input_set_personality(const char *);
82 struct anthy_input_context*
83 anthy_input_create_context(struct anthy_input_config* cfg);
84 void anthy_input_free_context(struct anthy_input_context* ictx);
85
86 /* pure function command */
87 void anthy_input_str(struct anthy_input_context* ictx, const char* str);
88 void anthy_input_next_candidate(struct anthy_input_context* ictx);
89 void anthy_input_prev_candidate(struct anthy_input_context* ictx);
90 void anthy_input_quit(struct anthy_input_context* ictx);
91 void anthy_input_erase_prev(struct anthy_input_context* ictx);
92 void anthy_input_erase_next(struct anthy_input_context* ictx);
93 void anthy_input_commit(struct anthy_input_context* ictx);
94 void anthy_input_move(struct anthy_input_context* ictx, int lr);
95 void anthy_input_resize(struct anthy_input_context* ictx, int lr);
96 void anthy_input_beginning_of_line(struct anthy_input_context* ictx);
97 void anthy_input_end_of_line(struct anthy_input_context* ictx);
98 void anthy_input_cut(struct anthy_input_context* ictx);
99
100 /* key oriented command */
101 void anthy_input_key(struct anthy_input_context* ictx, int c);
102 void anthy_input_space(struct anthy_input_context* ictx);
103
104 /* meta command */
105 int anthy_input_get_state(struct anthy_input_context* ictx);
106 struct anthy_input_preedit*
107 anthy_input_get_preedit(struct anthy_input_context* ictx);
108 void anthy_input_free_preedit(struct anthy_input_preedit* pedit);
109 int anthy_input_map_select(struct anthy_input_context* ictx, int map);
110 int anthy_input_get_selected_map(struct anthy_input_context* ictx);
111 struct anthy_input_segment* 
112 anthy_input_get_candidate(struct anthy_input_context* ictx, int cand_no);
113 void anthy_input_free_segment(struct anthy_input_segment* cand);
114 int anthy_input_select_candidate(struct anthy_input_context* ictx, int cand);
115
116 /* config */
117 struct anthy_input_config* anthy_input_create_config(void);
118 void anthy_input_free_config(struct anthy_input_config* cfg);
119 int anthy_input_edit_toggle_config(struct anthy_input_config *cfg, char tg);
120 int anthy_input_edit_rk_config(struct anthy_input_config *cfg, int map,
121                                const char *from, const char *to, const char *follow);
122 int anthy_input_clear_rk_config(struct anthy_input_config *cfg,
123                                 int use_default);
124 int anthy_input_break_into_roman_config(struct anthy_input_config* cfg, int f);
125 int anthy_input_preedit_mode_config(struct anthy_input_config* cfg, int f);
126 void anthy_input_change_config(struct anthy_input_config* cfg);
127
128 /* DEBUG API */
129 anthy_context_t
130 anthy_input_get_anthy_context(struct anthy_input_context *ictx);
131
132 #ifdef __cplusplus
133 }
134 #endif
135
136 #endif /* INPUT_H_INCLUDE */