1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * Copyright (C) Hiroyuki Ikezoe <poincare@ikezoe.net>
4 * Copyright (C) 2004 Takuro Ashie <ashie@homa.ne.jp>
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 #define Uses_SCIM_UTILITY
27 #define Uses_SCIM_IMENGINE
28 #define Uses_SCIM_CONFIG_BASE
36 #include <sys/types.h>
40 #include "scim_anthy_factory.h"
41 #include "scim_anthy_imengine.h"
42 #include "scim_anthy_prefs.h"
43 #include "scim_anthy_intl.h"
45 #define scim_module_init ise_engine_anthy_LTX_scim_module_init
46 #define scim_module_exit ise_engine_anthy_LTX_scim_module_exit
47 #define scim_imengine_module_init ise_engine_anthy_LTX_scim_imengine_module_init
48 #define scim_imengine_module_create_factory ise_engine_anthy_LTX_scim_imengine_module_create_factory
50 #define SCIM_CONFIG_IMENGINE_ANTHY_UUID "/IMEngine/Anthy/UUID-"
52 #ifndef SCIM_ANTHY_ICON_FILE
53 #define SCIM_ANTHY_ICON_FILE (SCIM_ICONDIR"/scim-anthy.png")
56 static ConfigPointer _scim_config (0);
59 void scim_module_init (void)
61 bindtextdomain (GETTEXT_PACKAGE, SCIM_ANTHY_LOCALEDIR);
62 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
65 void scim_module_exit (void)
68 _scim_config.reset ();
71 uint32 scim_imengine_module_init (const ConfigPointer &config)
73 SCIM_DEBUG_IMENGINE(1) << "Initialize Anthy Engine.\n";
75 _scim_config = config;
78 SCIM_DEBUG_IMENGINE(1) << "Failed to initialize Anthy Library!\n";
85 IMEngineFactoryPointer scim_imengine_module_create_factory (uint32 engine)
87 AnthyFactory *factory = 0;
90 factory = new AnthyFactory (
92 String ("065d7b20-dda2-47fb-8f94-3306d9a25e56"),
103 AnthyFactory::AnthyFactory (const String &lang,
105 const ConfigPointer &config)
108 m_input_mode (SCIM_ANTHY_CONFIG_INPUT_MODE_DEFAULT),
109 m_typing_method (SCIM_ANTHY_CONFIG_TYPING_METHOD_DEFAULT),
110 m_conversion_mode (SCIM_ANTHY_CONFIG_CONVERSION_MODE_DEFAULT),
111 m_period_style (SCIM_ANTHY_CONFIG_PERIOD_STYLE_DEFAULT),
112 m_symbol_style (SCIM_ANTHY_CONFIG_SYMBOL_STYLE_DEFAULT),
113 m_space_type (SCIM_ANTHY_CONFIG_SPACE_TYPE_DEFAULT),
114 m_ten_key_type (SCIM_ANTHY_CONFIG_TEN_KEY_TYPE_DEFAULT),
115 m_behavior_on_period (SCIM_ANTHY_CONFIG_BEHAVIOR_ON_PERIOD_DEFAULT),
116 m_behavior_on_focus_out (SCIM_ANTHY_CONFIG_BEHAVIOR_ON_FOCUS_OUT_DEFAULT),
117 m_show_candidates_label (SCIM_ANTHY_CONFIG_SHOW_CANDIDATES_LABEL_DEFAULT),
118 m_close_cand_win_on_select (SCIM_ANTHY_CONFIG_CLOSE_CAND_WIN_ON_SELECT_DEFAULT),
119 m_cand_win_page_size (SCIM_ANTHY_CONFIG_CAND_WIN_PAGE_SIZE_DEFAULT),
120 m_n_triggers_to_show_cand_win (SCIM_ANTHY_CONFIG_N_TRIGGERS_TO_SHOW_CAND_WIN_DEFAULT),
121 m_learn_on_manual_commit (SCIM_ANTHY_CONFIG_LEARN_ON_MANUAL_COMMIT_DEFAULT),
122 m_learn_on_auto_commit (SCIM_ANTHY_CONFIG_LEARN_ON_AUTO_COMMIT_DEFAULT),
123 m_romaji_half_symbol (SCIM_ANTHY_CONFIG_ROMAJI_HALF_SYMBOL_DEFAULT),
124 m_romaji_half_number (SCIM_ANTHY_CONFIG_ROMAJI_HALF_NUMBER_DEFAULT),
125 m_romaji_allow_split (SCIM_ANTHY_CONFIG_ROMAJI_ALLOW_SPLIT_DEFAULT),
126 m_romaji_pseudo_ascii_mode (SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_MODE_DEFAULT),
127 m_romaji_pseudo_ascii_blank_behavior (SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_BLANK_BEHAVIOR),
128 m_nicola_time (SCIM_ANTHY_CONFIG_NICOLA_TIME_DEFAULT),
129 m_dict_encoding (SCIM_ANTHY_CONFIG_DICT_ENCODING),
130 m_dict_admin_command (SCIM_ANTHY_CONFIG_DICT_ADMIN_COMMAND_DEFAULT),
131 m_add_word_command (SCIM_ANTHY_CONFIG_ADD_WORD_COMMAND_DEFAULT),
132 m_predict_on_input (SCIM_ANTHY_CONFIG_PREDICT_ON_INPUT_DEFAULT),
133 m_use_direct_key_on_predict (SCIM_ANTHY_CONFIG_USE_DIRECT_KEY_ON_PREDICT_DEFAULT),
134 m_show_input_mode_label (SCIM_ANTHY_CONFIG_SHOW_INPUT_MODE_LABEL_DEFAULT),
135 m_show_conv_mode_label (SCIM_ANTHY_CONFIG_SHOW_INPUT_MODE_LABEL_DEFAULT),
136 m_show_typing_method_label (SCIM_ANTHY_CONFIG_SHOW_TYPING_METHOD_LABEL_DEFAULT),
137 m_show_period_style_label (SCIM_ANTHY_CONFIG_SHOW_PERIOD_STYLE_LABEL_DEFAULT),
138 m_show_symbol_style_label (SCIM_ANTHY_CONFIG_SHOW_SYMBOL_STYLE_LABEL_DEFAULT),
139 m_show_dict_label (SCIM_ANTHY_CONFIG_SHOW_DICT_LABEL_DEFAULT),
140 m_show_dict_admin_label (SCIM_ANTHY_CONFIG_SHOW_DICT_ADMIN_LABEL_DEFAULT),
141 m_show_add_word_label (SCIM_ANTHY_CONFIG_SHOW_ADD_WORD_LABEL_DEFAULT),
142 m_preedit_style (SCIM_ANTHY_CONFIG_PREEDIT_STYLE_DEFAULT),
143 m_conversion_style (SCIM_ANTHY_CONFIG_CONVERSION_STYLE_DEFAULT),
144 m_selected_segment_style (SCIM_ANTHY_CONFIG_SELECTED_SEGMENT_STYLE_DEFAULT),
145 m_custom_romaji_table (NULL),
146 m_custom_kana_table (NULL),
147 m_custom_nicola_table (NULL),
148 m_kana_layout_ro_key (SCIM_ANTHY_CONFIG_KANA_LAYOUT_RO_KEY)
150 SCIM_DEBUG_IMENGINE(1) << "Create Anthy Factory :\n";
151 SCIM_DEBUG_IMENGINE(1) << " Lang : " << lang << "\n";
152 SCIM_DEBUG_IMENGINE(1) << " UUID : " << uuid << "\n";
154 if (lang.length () >= 2)
155 set_languages (lang);
158 reload_config (m_config);
159 m_reload_signal_connection = m_config->signal_connect_reload (slot (this, &AnthyFactory::reload_config));
162 AnthyFactory::~AnthyFactory ()
164 m_reload_signal_connection.disconnect ();
166 if (m_custom_romaji_table) {
167 delete m_custom_romaji_table;
168 m_custom_romaji_table = NULL;
171 if (m_custom_kana_table) {
172 delete m_custom_kana_table;
173 m_custom_kana_table = NULL;
176 if (m_custom_nicola_table) {
177 delete m_custom_nicola_table;
178 m_custom_nicola_table = NULL;
183 AnthyFactory::get_name () const
185 return utf8_mbstowcs (String ("Anthy"));
189 AnthyFactory::get_authors () const
191 const char *package =
192 PACKAGE "-" PACKAGE_VERSION "\n"
194 const char *authors =
195 _("Authors of scim-anthy:\n"
196 " Copyright (C) 2004,2005 Takuro Ashie <ashie@homa.ne.jp>\n"
197 " Copyright (C) 2004,2005 Hiroyuki Ikezoe <poincare@ikezoe.net>\n"
199 "Authors of Anthy:\n"
200 " Copyright (C) 2000-2005 Yusuke TABATA <yusuke@w5.dion.ne.jp>\n"
201 " Copyright (C) 2004-2005 Yuichi YOSHIDA <oxy@kmc.gr.jp>\n"
202 " You can find out all credits of Anthy from AUTHORS file in Anthy package.\n");
204 return utf8_mbstowcs (package) + utf8_mbstowcs (authors);
208 AnthyFactory::get_credits () const
210 return utf8_mbstowcs (
212 " SHIMODA Hiroshi <piro@p.club.ne.jp>\n"
215 " Gerrit Sangel <z0idberg@gmx.de>"
218 " UTUMI Hirosi <utuhiro78@yahoo.co.jp>\n"
219 " Yukiko Bando <ybando@k6.dion.ne.jp>\n"
220 " Mike Fabian <mfabian@suse.de>\n"
221 " David Oftedal <david@start.no>\n"
222 " Ryo Dairiki <ryo-dairiki@users.sourceforge.net>\n"
224 " AWASHIRO Ikuya <ikuya@oooug.jp>\n"
225 " Hatuka*nezumi <nezumi@jca.apc.org>\n"
226 " Teppei Tamra <tam-t@par.odn.ne.jp>\n"
227 " Akira TAGOH <at@gclab.org>\n"
228 " Tatsuki Sugiura <sugi@nemui.org>\n"
229 " Takashi Nakamoto <bluedwarf@bpost.plala.or.jp>"));
233 AnthyFactory::get_help () const
236 _("Basic operation:\n"
240 _("1. Switch input mode:\n"
241 " You can switch on/off Japanese input mode by pressing Zenkaku_Hankaku key\n"
242 " or Control+J. Or you can rotate all input modes by pressing Control+,\n"
247 _("2. Input Japanese hiragana and katakana:\n"
248 " You can input Japanese hiragana and katakana by inputting romaji.\n"
249 " The Romaji table can be found out from the \"Anthy\" section of the setup\n"
250 " window in SCIM or SKIM.\n"
251 " If you want to hiragana and katakana directly by using Japanese keyboard,\n"
252 " please press Alt + Romaji key or Conrol+\\ key to switch typing method.\n"
256 _("3. Convert hiragana or katakana to Japanese kanji\n"
257 " After inputting hiragana or katakana, you can convert it to Japanese\n"
258 " kanji by pressing Space key. Then it will show some candidates. You can\n"
259 " select the next candidate by pressing Space key, and can commit it by\n"
260 " pressing Enter key.\n"
261 " If you input a sentense, Anthy will split it to some segments. You can\n"
262 " select the next or previous segment by pressing left or right cursor key,\n"
263 " and can extend or shrink the selected segment by pressing Shift + left or\n"
264 " right cursor key.\n"
268 _("4. Other key bindings:\n"
269 " You can find out all key bindings definition of scim-anthy from \"Anthy\"\n"
270 " section on setup window of SCIM or SKIM.\n");
272 return utf8_mbstowcs (title)
273 + utf8_mbstowcs (text1)
274 + utf8_mbstowcs (text2)
275 + utf8_mbstowcs (text3)
276 + utf8_mbstowcs (text4);
280 AnthyFactory::get_uuid () const
286 AnthyFactory::get_icon_file () const
288 return String (SCIM_ANTHY_ICON_FILE);
291 IMEngineInstancePointer
292 AnthyFactory::create_instance (const String &encoding, int id)
294 return new AnthyInstance (this, encoding, id);
298 AnthyFactory::append_config_listener (AnthyInstance *listener)
301 std::vector<AnthyInstance*>::iterator it;
302 for (it = m_config_listeners.begin();
303 it != m_config_listeners.end();
306 if (*it == listener) {
313 m_config_listeners.push_back (listener);
317 AnthyFactory::remove_config_listener (AnthyInstance *listener)
319 std::vector<AnthyInstance*>::iterator it;
320 for (it = m_config_listeners.begin();
321 it != m_config_listeners.end();
324 if (*it == listener) {
325 m_config_listeners.erase (it);
333 #define APPEND_ACTION(key, func) \
335 String name = "func", str; \
336 str = config->read (String (SCIM_ANTHY_CONFIG_##key##_KEY), \
337 String (SCIM_ANTHY_CONFIG_##key##_KEY_DEFAULT)); \
338 m_actions.push_back (Action (name, str, &AnthyInstance::func)); \
341 #define APPEND_ACTION(key, func) \
343 String name = #key, str; \
346 str2 = String (SCIM_ANTHY_CONFIG_##key##_KEY); \
347 str3 = String ("/IMEngine/Anthy/"); \
348 if (str2.length () > str3.length ()) { \
349 str2 = str2.substr (str3.length (), \
350 str2.length () - str3.length ()); \
351 style.get_string (str, section_key, str2); \
353 } else if (config) { \
354 str = config->read (String (SCIM_ANTHY_CONFIG_##key##_KEY), \
355 String (SCIM_ANTHY_CONFIG_##key##_KEY_DEFAULT)); \
357 m_actions.push_back (Action (name, str, func)); \
362 #define ANTHY_DEFINE_ACTION(func) \
364 func (AnthyInstance *anthy) \
366 return anthy->func (); \
369 ANTHY_DEFINE_ACTION (action_do_nothing);
370 ANTHY_DEFINE_ACTION (action_commit_follow_preference);
371 ANTHY_DEFINE_ACTION (action_commit_reverse_preference);
372 ANTHY_DEFINE_ACTION (action_convert);
373 ANTHY_DEFINE_ACTION (action_predict);
374 ANTHY_DEFINE_ACTION (action_revert);
375 ANTHY_DEFINE_ACTION (action_cancel_all);
376 ANTHY_DEFINE_ACTION (action_back);
377 ANTHY_DEFINE_ACTION (action_delete);
378 ANTHY_DEFINE_ACTION (action_insert_space);
379 ANTHY_DEFINE_ACTION (action_insert_alternative_space);
380 ANTHY_DEFINE_ACTION (action_insert_half_space);
381 ANTHY_DEFINE_ACTION (action_insert_wide_space);
382 ANTHY_DEFINE_ACTION (action_move_caret_first);
383 ANTHY_DEFINE_ACTION (action_move_caret_last);
384 ANTHY_DEFINE_ACTION (action_move_caret_forward);
385 ANTHY_DEFINE_ACTION (action_move_caret_backward);
386 ANTHY_DEFINE_ACTION (action_select_first_segment);
387 ANTHY_DEFINE_ACTION (action_select_last_segment);
388 ANTHY_DEFINE_ACTION (action_select_next_segment);
389 ANTHY_DEFINE_ACTION (action_select_prev_segment);
390 ANTHY_DEFINE_ACTION (action_shrink_segment);
391 ANTHY_DEFINE_ACTION (action_expand_segment);
392 ANTHY_DEFINE_ACTION (action_commit_first_segment);
393 ANTHY_DEFINE_ACTION (action_commit_selected_segment);
394 ANTHY_DEFINE_ACTION (action_commit_first_segment_reverse_preference);
395 ANTHY_DEFINE_ACTION (action_commit_selected_segment_reverse_preference);
396 ANTHY_DEFINE_ACTION (action_select_first_candidate);
397 ANTHY_DEFINE_ACTION (action_select_last_candidate);
398 ANTHY_DEFINE_ACTION (action_select_next_candidate);
399 ANTHY_DEFINE_ACTION (action_select_prev_candidate);
400 ANTHY_DEFINE_ACTION (action_candidates_page_up);
401 ANTHY_DEFINE_ACTION (action_candidates_page_down);
402 ANTHY_DEFINE_ACTION (action_select_candidate_1);
403 ANTHY_DEFINE_ACTION (action_select_candidate_2);
404 ANTHY_DEFINE_ACTION (action_select_candidate_3);
405 ANTHY_DEFINE_ACTION (action_select_candidate_4);
406 ANTHY_DEFINE_ACTION (action_select_candidate_5);
407 ANTHY_DEFINE_ACTION (action_select_candidate_6);
408 ANTHY_DEFINE_ACTION (action_select_candidate_7);
409 ANTHY_DEFINE_ACTION (action_select_candidate_8);
410 ANTHY_DEFINE_ACTION (action_select_candidate_9);
411 ANTHY_DEFINE_ACTION (action_select_candidate_10);
412 ANTHY_DEFINE_ACTION (action_convert_char_type_forward);
413 ANTHY_DEFINE_ACTION (action_convert_char_type_backward);
414 ANTHY_DEFINE_ACTION (action_convert_to_hiragana);
415 ANTHY_DEFINE_ACTION (action_convert_to_katakana);
416 ANTHY_DEFINE_ACTION (action_convert_to_half);
417 ANTHY_DEFINE_ACTION (action_convert_to_half_katakana);
418 ANTHY_DEFINE_ACTION (action_convert_to_latin);
419 ANTHY_DEFINE_ACTION (action_convert_to_wide_latin);
420 ANTHY_DEFINE_ACTION (action_reconvert);
421 ANTHY_DEFINE_ACTION (action_on_off);
422 ANTHY_DEFINE_ACTION (action_circle_input_mode);
423 ANTHY_DEFINE_ACTION (action_circle_kana_mode);
424 ANTHY_DEFINE_ACTION (action_circle_typing_method);
425 ANTHY_DEFINE_ACTION (action_latin_mode);
426 ANTHY_DEFINE_ACTION (action_wide_latin_mode);
427 ANTHY_DEFINE_ACTION (action_hiragana_mode);
428 ANTHY_DEFINE_ACTION (action_katakana_mode);
429 ANTHY_DEFINE_ACTION (action_half_katakana_mode);
430 ANTHY_DEFINE_ACTION (action_cancel_pseudo_ascii_mode);
431 ANTHY_DEFINE_ACTION (action_launch_dict_admin_tool);
432 ANTHY_DEFINE_ACTION (action_add_word);
435 AnthyFactory::reload_config (const ConfigPointer &config)
441 = config->read (String (SCIM_ANTHY_CONFIG_INPUT_MODE),
442 String (SCIM_ANTHY_CONFIG_INPUT_MODE_DEFAULT));
445 = config->read (String (SCIM_ANTHY_CONFIG_TYPING_METHOD),
446 String (SCIM_ANTHY_CONFIG_TYPING_METHOD_DEFAULT));
449 = config->read (String (SCIM_ANTHY_CONFIG_CONVERSION_MODE),
450 String (SCIM_ANTHY_CONFIG_CONVERSION_MODE_DEFAULT));
453 = config->read (String (SCIM_ANTHY_CONFIG_PERIOD_STYLE),
454 String (SCIM_ANTHY_CONFIG_PERIOD_STYLE_DEFAULT));
457 = config->read (String (SCIM_ANTHY_CONFIG_SYMBOL_STYLE),
458 String (SCIM_ANTHY_CONFIG_SYMBOL_STYLE_DEFAULT));
461 = config->read (String (SCIM_ANTHY_CONFIG_SPACE_TYPE),
462 String (SCIM_ANTHY_CONFIG_SPACE_TYPE_DEFAULT));
465 = config->read (String (SCIM_ANTHY_CONFIG_TEN_KEY_TYPE),
466 String (SCIM_ANTHY_CONFIG_TEN_KEY_TYPE_DEFAULT));
469 = config->read (String (SCIM_ANTHY_CONFIG_BEHAVIOR_ON_PERIOD),
470 String (SCIM_ANTHY_CONFIG_BEHAVIOR_ON_PERIOD_DEFAULT));
472 m_behavior_on_focus_out
473 = config->read (String (SCIM_ANTHY_CONFIG_BEHAVIOR_ON_FOCUS_OUT),
474 String (SCIM_ANTHY_CONFIG_BEHAVIOR_ON_FOCUS_OUT_DEFAULT));
477 = config->read (String (SCIM_ANTHY_CONFIG_CAND_WIN_PAGE_SIZE),
478 SCIM_ANTHY_CONFIG_CAND_WIN_PAGE_SIZE_DEFAULT);
480 m_show_candidates_label
481 = config->read (String (SCIM_ANTHY_CONFIG_SHOW_CANDIDATES_LABEL),
482 SCIM_ANTHY_CONFIG_SHOW_CANDIDATES_LABEL_DEFAULT);
484 m_close_cand_win_on_select
485 = config->read (String (SCIM_ANTHY_CONFIG_CLOSE_CAND_WIN_ON_SELECT),
486 SCIM_ANTHY_CONFIG_CLOSE_CAND_WIN_ON_SELECT_DEFAULT);
488 m_n_triggers_to_show_cand_win
489 = config->read (String (SCIM_ANTHY_CONFIG_N_TRIGGERS_TO_SHOW_CAND_WIN),
490 SCIM_ANTHY_CONFIG_N_TRIGGERS_TO_SHOW_CAND_WIN_DEFAULT);
492 m_learn_on_manual_commit
493 = config->read (String (SCIM_ANTHY_CONFIG_LEARN_ON_MANUAL_COMMIT),
494 SCIM_ANTHY_CONFIG_LEARN_ON_MANUAL_COMMIT_DEFAULT);
496 m_learn_on_auto_commit
497 = config->read (String (SCIM_ANTHY_CONFIG_LEARN_ON_AUTO_COMMIT),
498 SCIM_ANTHY_CONFIG_LEARN_ON_AUTO_COMMIT_DEFAULT);
501 = config->read (String (SCIM_ANTHY_CONFIG_ROMAJI_HALF_SYMBOL),
502 SCIM_ANTHY_CONFIG_ROMAJI_HALF_SYMBOL_DEFAULT);
505 = config->read (String (SCIM_ANTHY_CONFIG_ROMAJI_HALF_NUMBER),
506 SCIM_ANTHY_CONFIG_ROMAJI_HALF_NUMBER_DEFAULT);
509 = config->read (String (SCIM_ANTHY_CONFIG_ROMAJI_ALLOW_SPLIT),
510 SCIM_ANTHY_CONFIG_ROMAJI_ALLOW_SPLIT_DEFAULT);
512 m_romaji_pseudo_ascii_mode
513 = config->read (String (SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_MODE),
514 SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_MODE_DEFAULT);
516 m_romaji_pseudo_ascii_blank_behavior
517 = config->read (String (SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_BLANK_BEHAVIOR),
518 SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_BLANK_BEHAVIOR_DEFAULT);
521 = config->read (String (SCIM_ANTHY_CONFIG_NICOLA_TIME),
522 SCIM_ANTHY_CONFIG_NICOLA_TIME_DEFAULT);
524 str = config->read (String (SCIM_ANTHY_CONFIG_LEFT_THUMB_SHIFT_KEY),
525 String (SCIM_ANTHY_CONFIG_LEFT_THUMB_SHIFT_KEY_DEFAULT));
526 scim_string_to_key_list (m_left_thumb_keys, str);
528 str = config->read (String (SCIM_ANTHY_CONFIG_RIGHT_THUMB_SHIFT_KEY),
529 String (SCIM_ANTHY_CONFIG_RIGHT_THUMB_SHIFT_KEY_DEFAULT));
530 scim_string_to_key_list (m_right_thumb_keys, str);
534 = config->read (String (SCIM_ANTHY_CONFIG_DICT_ENCODING),
535 String (SCIM_ANTHY_CONFIG_DICT_ENCODING_DEFAULT));
538 = config->read (String (SCIM_ANTHY_CONFIG_DICT_ADMIN_COMMAND),
539 String (SCIM_ANTHY_CONFIG_DICT_ADMIN_COMMAND_DEFAULT));
542 = config->read (String (SCIM_ANTHY_CONFIG_ADD_WORD_COMMAND),
543 String (SCIM_ANTHY_CONFIG_ADD_WORD_COMMAND_DEFAULT));
546 = config->read (String (SCIM_ANTHY_CONFIG_PREDICT_ON_INPUT),
547 SCIM_ANTHY_CONFIG_PREDICT_ON_INPUT_DEFAULT);
549 m_use_direct_key_on_predict
550 = config->read (String (SCIM_ANTHY_CONFIG_USE_DIRECT_KEY_ON_PREDICT),
551 SCIM_ANTHY_CONFIG_USE_DIRECT_KEY_ON_PREDICT_DEFAULT);
553 m_show_input_mode_label
554 = config->read (String (SCIM_ANTHY_CONFIG_SHOW_INPUT_MODE_LABEL),
555 SCIM_ANTHY_CONFIG_SHOW_INPUT_MODE_LABEL_DEFAULT);
557 m_show_conv_mode_label
558 = config->read (String (SCIM_ANTHY_CONFIG_SHOW_CONVERSION_MODE_LABEL),
559 SCIM_ANTHY_CONFIG_SHOW_CONVERSION_MODE_LABEL_DEFAULT);
561 m_show_typing_method_label
562 = config->read (String (SCIM_ANTHY_CONFIG_SHOW_TYPING_METHOD_LABEL),
563 SCIM_ANTHY_CONFIG_SHOW_TYPING_METHOD_LABEL_DEFAULT);
565 m_show_period_style_label
566 = config->read (String (SCIM_ANTHY_CONFIG_SHOW_PERIOD_STYLE_LABEL),
567 SCIM_ANTHY_CONFIG_SHOW_PERIOD_STYLE_LABEL_DEFAULT);
569 m_show_symbol_style_label
570 = config->read (String (SCIM_ANTHY_CONFIG_SHOW_SYMBOL_STYLE_LABEL),
571 SCIM_ANTHY_CONFIG_SHOW_SYMBOL_STYLE_LABEL_DEFAULT);
574 = config->read (String (SCIM_ANTHY_CONFIG_SHOW_DICT_LABEL),
575 SCIM_ANTHY_CONFIG_SHOW_DICT_LABEL_DEFAULT);
577 m_show_dict_admin_label
578 = config->read (String (SCIM_ANTHY_CONFIG_SHOW_DICT_ADMIN_LABEL),
579 SCIM_ANTHY_CONFIG_SHOW_DICT_ADMIN_LABEL_DEFAULT);
581 m_show_add_word_label
582 = config->read (String (SCIM_ANTHY_CONFIG_SHOW_ADD_WORD_LABEL),
583 SCIM_ANTHY_CONFIG_SHOW_ADD_WORD_LABEL_DEFAULT);
586 int red, green, blue;
588 // preedit string color
590 = config->read (String (SCIM_ANTHY_CONFIG_PREEDIT_STYLE),
591 String (SCIM_ANTHY_CONFIG_PREEDIT_STYLE_DEFAULT));
592 str = config->read (String (SCIM_ANTHY_CONFIG_PREEDIT_FG_COLOR),
593 String (SCIM_ANTHY_CONFIG_PREEDIT_FG_COLOR_DEFAULT));
594 sscanf (str.c_str (), "#%02X%02X%02X", &red, &green, &blue);
595 m_preedit_fg_color = SCIM_RGB_COLOR (red, green, blue);
597 str = config->read (String (SCIM_ANTHY_CONFIG_PREEDIT_BG_COLOR),
598 String (SCIM_ANTHY_CONFIG_PREEDIT_BG_COLOR_DEFAULT));
599 sscanf (str.c_str (), "#%02X%02X%02X", &red, &green, &blue);
600 m_preedit_bg_color = SCIM_RGB_COLOR (red, green, blue);
602 // conversion string color
604 = config->read (String (SCIM_ANTHY_CONFIG_CONVERSION_STYLE),
605 String (SCIM_ANTHY_CONFIG_CONVERSION_STYLE_DEFAULT));
606 str = config->read (String (SCIM_ANTHY_CONFIG_CONVERSION_FG_COLOR),
607 String (SCIM_ANTHY_CONFIG_CONVERSION_FG_COLOR_DEFAULT));
608 sscanf (str.c_str (), "#%02X%02X%02X", &red, &green, &blue);
609 m_conversion_fg_color = SCIM_RGB_COLOR (red, green, blue);
611 str = config->read (String (SCIM_ANTHY_CONFIG_CONVERSION_BG_COLOR),
612 String (SCIM_ANTHY_CONFIG_CONVERSION_BG_COLOR_DEFAULT));
613 sscanf (str.c_str (), "#%02X%02X%02X", &red, &green, &blue);
614 m_conversion_bg_color = SCIM_RGB_COLOR (red, green, blue);
616 // selected segment color
617 m_selected_segment_style
618 = config->read (String (SCIM_ANTHY_CONFIG_SELECTED_SEGMENT_STYLE),
619 String (SCIM_ANTHY_CONFIG_SELECTED_SEGMENT_STYLE_DEFAULT));
620 str = config->read (String (SCIM_ANTHY_CONFIG_SELECTED_SEGMENT_FG_COLOR),
621 String (SCIM_ANTHY_CONFIG_SELECTED_SEGMENT_FG_COLOR_DEFAULT));
622 sscanf (str.c_str (), "#%02X%02X%02X", &red, &green, &blue);
623 m_selected_segment_fg_color = SCIM_RGB_COLOR (red, green, blue);
625 str = config->read (String (SCIM_ANTHY_CONFIG_SELECTED_SEGMENT_BG_COLOR),
626 String (SCIM_ANTHY_CONFIG_SELECTED_SEGMENT_BG_COLOR_DEFAULT));
627 sscanf (str.c_str (), "#%02X%02X%02X", &red, &green, &blue);
628 m_selected_segment_bg_color = SCIM_RGB_COLOR (red, green, blue);
636 const char *section_key = "KeyBindings";
637 file = config->read (String (SCIM_ANTHY_CONFIG_KEY_THEME_FILE),
638 String (SCIM_ANTHY_CONFIG_KEY_THEME_FILE_DEFAULT));
639 loaded = style.load (file.c_str ());
645 APPEND_ACTION (CONVERT, action_convert);
646 APPEND_ACTION (PREDICT, action_predict);
649 APPEND_ACTION (CANDIDATES_PAGE_UP, action_candidates_page_up);
650 APPEND_ACTION (CANDIDATES_PAGE_DOWN, action_candidates_page_down);
651 APPEND_ACTION (SELECT_CANDIDATE_1, action_select_candidate_1);
652 APPEND_ACTION (SELECT_CANDIDATE_2, action_select_candidate_2);
653 APPEND_ACTION (SELECT_CANDIDATE_3, action_select_candidate_3);
654 APPEND_ACTION (SELECT_CANDIDATE_4, action_select_candidate_4);
655 APPEND_ACTION (SELECT_CANDIDATE_5, action_select_candidate_5);
656 APPEND_ACTION (SELECT_CANDIDATE_6, action_select_candidate_6);
657 APPEND_ACTION (SELECT_CANDIDATE_7, action_select_candidate_7);
658 APPEND_ACTION (SELECT_CANDIDATE_8, action_select_candidate_8);
659 APPEND_ACTION (SELECT_CANDIDATE_9, action_select_candidate_9);
660 APPEND_ACTION (SELECT_CANDIDATE_10, action_select_candidate_10);
661 APPEND_ACTION (SELECT_FIRST_CANDIDATE, action_select_first_candidate);
662 APPEND_ACTION (SELECT_LAST_CANDIDATE, action_select_last_candidate);
663 APPEND_ACTION (SELECT_NEXT_CANDIDATE, action_select_next_candidate);
664 APPEND_ACTION (SELECT_PREV_CANDIDATE, action_select_prev_candidate);
667 APPEND_ACTION (SELECT_FIRST_SEGMENT, action_select_first_segment);
668 APPEND_ACTION (SELECT_LAST_SEGMENT, action_select_last_segment);
669 APPEND_ACTION (SELECT_NEXT_SEGMENT, action_select_next_segment);
670 APPEND_ACTION (SELECT_PREV_SEGMENT, action_select_prev_segment);
671 APPEND_ACTION (SHRINK_SEGMENT, action_shrink_segment);
672 APPEND_ACTION (EXPAND_SEGMENT, action_expand_segment);
673 APPEND_ACTION (COMMIT_FIRST_SEGMENT, action_commit_first_segment);
674 APPEND_ACTION (COMMIT_SELECTED_SEGMENT, action_commit_selected_segment);
675 APPEND_ACTION (COMMIT_FIRST_SEGMENT_REVERSE_LEARN,
676 action_commit_first_segment_reverse_preference);
677 APPEND_ACTION (COMMIT_SELECTED_SEGMENT_REVERSE_LEARN,
678 action_commit_selected_segment_reverse_preference);
680 // direct convert keys
681 APPEND_ACTION (CONV_CHAR_TYPE_FORWARD, action_convert_char_type_forward);
682 APPEND_ACTION (CONV_CHAR_TYPE_BACKWARD, action_convert_char_type_backward);
683 APPEND_ACTION (CONV_TO_HIRAGANA, action_convert_to_hiragana);
684 APPEND_ACTION (CONV_TO_KATAKANA, action_convert_to_katakana);
685 APPEND_ACTION (CONV_TO_HALF, action_convert_to_half);
686 APPEND_ACTION (CONV_TO_HALF_KATAKANA, action_convert_to_half_katakana);
687 APPEND_ACTION (CONV_TO_LATIN, action_convert_to_latin);
688 APPEND_ACTION (CONV_TO_WIDE_LATIN, action_convert_to_wide_latin);
691 APPEND_ACTION (CANCEL_PSEUDO_ASCII_MODE,action_cancel_pseudo_ascii_mode);
694 APPEND_ACTION (MOVE_CARET_FIRST, action_move_caret_first);
695 APPEND_ACTION (MOVE_CARET_LAST, action_move_caret_last);
696 APPEND_ACTION (MOVE_CARET_FORWARD, action_move_caret_forward);
697 APPEND_ACTION (MOVE_CARET_BACKWARD, action_move_caret_backward);
700 APPEND_ACTION (BACKSPACE, action_back);
701 APPEND_ACTION (DELETE, action_delete);
702 APPEND_ACTION (COMMIT, action_commit_follow_preference);
703 APPEND_ACTION (COMMIT_REVERSE_LEARN, action_commit_reverse_preference);
704 APPEND_ACTION (CANCEL, action_revert);
705 APPEND_ACTION (CANCEL_ALL, action_cancel_all);
706 APPEND_ACTION (INSERT_SPACE, action_insert_space);
707 APPEND_ACTION (INSERT_ALT_SPACE, action_insert_alternative_space);
708 APPEND_ACTION (INSERT_HALF_SPACE, action_insert_half_space);
709 APPEND_ACTION (INSERT_WIDE_SPACE, action_insert_wide_space);
712 APPEND_ACTION (ON_OFF, action_on_off);
713 APPEND_ACTION (CIRCLE_INPUT_MODE, action_circle_input_mode);
714 APPEND_ACTION (CIRCLE_KANA_MODE, action_circle_kana_mode);
715 APPEND_ACTION (CIRCLE_TYPING_METHOD, action_circle_typing_method);
716 APPEND_ACTION (LATIN_MODE, action_latin_mode);
717 APPEND_ACTION (WIDE_LATIN_MODE, action_wide_latin_mode);
718 APPEND_ACTION (HIRAGANA_MODE, action_hiragana_mode);
719 APPEND_ACTION (KATAKANA_MODE, action_katakana_mode);
720 APPEND_ACTION (HALF_KATAKANA_MODE, action_half_katakana_mode);
723 APPEND_ACTION (DICT_ADMIN, action_launch_dict_admin_tool);
724 APPEND_ACTION (ADD_WORD, action_add_word);
727 APPEND_ACTION (RECONVERT, action_reconvert);
730 APPEND_ACTION (DO_NOTHING, action_do_nothing);
732 // load custom romaji table
733 const char *section_romaji = "RomajiTable/FundamentalTable";
734 file = config->read (String (SCIM_ANTHY_CONFIG_ROMAJI_THEME_FILE),
735 String (SCIM_ANTHY_CONFIG_ROMAJI_THEME_FILE_DEFAULT));
736 if (m_custom_romaji_table) {
737 delete m_custom_romaji_table;
738 m_custom_romaji_table = NULL;
740 if (!file.empty() && style.load (file.c_str ())) {
741 m_custom_romaji_table = style.get_key2kana_table (section_romaji);
744 // load custom kana table
745 const char *section_kana = "KanaTable/FundamentalTable";
746 file = config->read (String (SCIM_ANTHY_CONFIG_KANA_LAYOUT_FILE),
747 String (SCIM_ANTHY_CONFIG_KANA_LAYOUT_FILE_DEFAULT));
748 if (m_custom_kana_table) {
749 delete m_custom_kana_table;
750 m_custom_kana_table = NULL;
752 if (!file.empty () && style.load (file.c_str ())) {
753 m_custom_kana_table = style.get_key2kana_table (section_kana);
756 // load custom NICOLA table
757 const char *section_nicola = "NICOLATable/FundamentalTable";
758 file = config->read (String (SCIM_ANTHY_CONFIG_NICOLA_LAYOUT_FILE),
759 String (SCIM_ANTHY_CONFIG_NICOLA_LAYOUT_FILE_DEFAULT));
760 if (m_custom_nicola_table) {
761 delete m_custom_nicola_table;
762 m_custom_nicola_table = NULL;
764 if (!file.empty () && style.load (file.c_str ())) {
765 m_custom_nicola_table = style.get_key2kana_table (section_nicola);
770 = config->read (String (SCIM_ANTHY_CONFIG_KANA_LAYOUT_RO_KEY),
771 String (SCIM_ANTHY_CONFIG_KANA_LAYOUT_RO_KEY_DEFAULT));
774 // reload config for all instance
775 std::vector<AnthyInstance*>::iterator it;
776 for (it = m_config_listeners.begin();
777 it != m_config_listeners.end();
780 (*it)->reload_config (config);