1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * Copyright (C) 2004 Hiroyuki Ikezoe
4 * Copyright (C) 2004 Takuro Ashie
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * The original code is scim_uim_imengine.cpp in scim-uim-0.1.3.
23 * Copyright (C) 2004 James Su <suzhe@tsinghua.org.cn>
26 #ifndef __SCIM_ANTHY_IMENGINE_H__
27 #define __SCIM_ANTHY_IMENGINE_H__
29 #define Uses_SCIM_IMENGINE
30 #define Uses_SCIM_CONFIG_BASE
32 #include <anthy/anthy.h>
34 #include "scim_anthy_preedit.h"
35 #include "scim_anthy_key2kana_table.h"
38 using namespace scim_anthy;
42 namespace scim_anthy {
45 SCIM_ANTHY_CONVERSION_MULTI_SEGMENT,
46 SCIM_ANTHY_CONVERSION_SINGLE_SEGMENT,
47 SCIM_ANTHY_CONVERSION_MULTI_SEGMENT_IMMEDIATE,
48 SCIM_ANTHY_CONVERSION_SINGLE_SEGMENT_IMMEDIATE,
51 typedef void (*timeout_func) (void *data);
52 typedef void (*delete_func) (void *data);
63 TimeoutClosure (uint32 time_msec,
64 timeout_func timeout_fn,
66 delete_func delete_fn)
67 : m_time_msec (time_msec),
68 m_timeout_fn (timeout_fn),
70 m_delete_fn (delete_fn)
72 virtual ~TimeoutClosure ()
74 if (m_delete_fn && m_data)
78 void close (void) { m_timeout_fn (m_data); }
81 timeout_func m_timeout_fn;
83 delete_func m_delete_fn;
86 typedef std::map<int, TimeoutClosure> TimeoutClosures;
90 class AnthyInstance : public IMEngineInstanceBase
93 AnthyInstance (AnthyFactory *factory,
94 const String &encoding,
96 virtual ~AnthyInstance ();
98 virtual bool process_key_event (const KeyEvent& key);
99 virtual void move_preedit_caret (unsigned int pos);
100 virtual void select_candidate (unsigned int item);
101 virtual void update_lookup_table_page_size(unsigned int page_size);
102 virtual void lookup_table_page_up (void);
103 virtual void lookup_table_page_down (void);
104 virtual void reset (void);
105 virtual void focus_in (void);
106 virtual void focus_out (void);
107 virtual void trigger_property (const String &property);
108 virtual void process_helper_event (const String &helper_uuid,
109 const Transaction &trans);
111 virtual void reload_config (const ConfigPointer &config);
112 virtual void flush ();
116 bool action_do_nothing (void);
118 bool action_convert (void);
119 bool action_predict (void);
120 bool action_revert (void);
121 bool action_cancel_all (void);
122 bool action_commit_follow_preference (void);
123 bool action_commit_reverse_preference (void);
124 bool action_commit_first_segment (void);
125 bool action_commit_selected_segment (void);
126 bool action_commit_first_segment_reverse_preference
128 bool action_commit_selected_segment_reverse_preference
130 bool action_back (void);
131 bool action_delete (void);
132 bool action_insert_space (void);
133 bool action_insert_alternative_space (void);
134 bool action_insert_half_space (void);
135 bool action_insert_wide_space (void);
137 bool action_move_caret_backward (void);
138 bool action_move_caret_forward (void);
139 bool action_move_caret_first (void);
140 bool action_move_caret_last (void);
142 bool action_select_prev_segment (void);
143 bool action_select_next_segment (void);
144 bool action_select_first_segment (void);
145 bool action_select_last_segment (void);
146 bool action_shrink_segment (void);
147 bool action_expand_segment (void);
149 bool action_select_first_candidate (void);
150 bool action_select_last_candidate (void);
151 bool action_select_next_candidate (void);
152 bool action_select_prev_candidate (void);
153 bool action_candidates_page_up (void);
154 bool action_candidates_page_down (void);
156 bool action_select_candidate_1 (void);
157 bool action_select_candidate_2 (void);
158 bool action_select_candidate_3 (void);
159 bool action_select_candidate_4 (void);
160 bool action_select_candidate_5 (void);
161 bool action_select_candidate_6 (void);
162 bool action_select_candidate_7 (void);
163 bool action_select_candidate_8 (void);
164 bool action_select_candidate_9 (void);
165 bool action_select_candidate_10 (void);
167 bool action_convert_to_hiragana (void);
168 bool action_convert_to_katakana (void);
169 bool action_convert_to_half (void);
170 bool action_convert_to_half_katakana (void);
171 bool action_convert_to_latin (void);
172 bool action_convert_to_wide_latin (void);
173 bool action_convert_char_type_forward (void);
174 bool action_convert_char_type_backward (void);
175 bool action_reconvert (void);
177 bool action_on_off (void);
179 bool action_circle_input_mode (void);
180 bool action_circle_kana_mode (void);
181 bool action_circle_typing_method (void);
183 bool action_latin_mode (void);
184 bool action_wide_latin_mode (void);
185 bool action_hiragana_mode (void);
186 bool action_katakana_mode (void);
187 bool action_half_katakana_mode (void);
188 bool action_cancel_pseudo_ascii_mode (void);
190 bool action_add_word (void);
191 bool action_launch_dict_admin_tool (void);
193 void actoin_register_word (void);
200 get_typing_method (void);
202 get_input_mode (void);
203 int timeout_add (uint32 time_msec,
204 timeout_func timeout_fn,
206 delete_func delete_fn = NULL);
207 void timeout_remove (uint32 id);
208 int get_pseudo_ascii_mode (void);
211 /* processing key event */
212 bool process_key_event_input (const KeyEvent &key);
213 bool process_key_event_lookup_keybind (const KeyEvent &key);
214 bool process_key_event_latin_mode (const KeyEvent &key);
215 bool process_key_event_wide_latin_mode (const KeyEvent &key);
218 void set_preedition (void);
219 void set_aux_string (void);
220 void set_lookup_table (void);
221 void unset_lookup_table (void);
222 void install_properties (void);
223 void set_input_mode (InputMode mode);
224 void set_conversion_mode (ConversionMode mode);
225 void set_typing_method (TypingMethod method);
226 void set_period_style (PeriodStyle period,
228 void set_symbol_style (BracketStyle bracket,
230 bool is_selecting_candidates (void);
231 void select_candidate_no_direct (unsigned int item);
232 bool convert_kana (CandidateType type);
234 bool action_commit (bool learn);
235 bool action_select_candidate (unsigned int i);
237 bool is_single_segment (void);
238 bool is_realtime_conversion (void);
241 bool is_nicola_thumb_shift_key (const KeyEvent &key);
244 AnthyFactory *m_factory;
250 bool m_preedit_string_visible;
252 /* for candidates window */
253 CommonLookupTable m_lookup_table;
254 bool m_lookup_table_visible;
255 unsigned int m_n_conv_key_pressed;
257 /* for toggling latin and wide latin */
258 InputMode m_prev_input_mode;
261 PropertyList m_properties;
264 ConversionMode m_conv_mode;
270 bool m_helper_started;
273 uint32 m_timeout_id_seq;
274 TimeoutClosures m_closures;
276 #endif /* __SCIM_ANTHY_IMENGINE_H__ */
278 vi:ts=4:nowrap:ai:expandtab