Akira TAGOH
at****@gclab*****
2006年 7月 11日 (火) 00:00:21 JST
たごうです。 >>>>> On Wed, 5 Jul 2006 23:05:05 +0900, >>>>> "TA" == Takuro Ashie <ashie****@homa*****> wrote: TA> 足永です。 TA> On Wed, 05 Jul 2006 22:29:08 +0900 (JST) TA> Akira TAGOH <at****@gclab*****> wrote: >> SCIMAnthyDevelopの1.2.0の項目にあがっている「pseudo ascii mode >> の改善」ですが、やっと時間がとれそうなので、今週中になんとか >> したいと思います。 TA> ワクワクテカテカ Pangoのバグを踏んでしまってちょっと手間取りましたが、とりあ えず要件を満たしてそうなので、送ってしまいます。 例によってどなたか追試してもらえると助かります。以前のパッチ + typo fixもしくはCVSにそのまま適用できるはずです。 既知の問題点として、空白を入れた際にpreedit行に下線が付きま せん。ただし、その後別の文字が入力されると下線が付きます。 調べた限りでは、Pangoのバグのようで、文字列の最後に空白があ る場合、PangoAttributesのstart_indexおよびend_indexの範囲内 にあっても無視されるようです。 pseudo ASCII modeのキャンセルキーを追加しましたが、もし別の カテゴリがよさげなら移動してもらって問題ないです。デフォルト 値は何も割り当てられていません。 # 最初shift+KeyReleaseにしようと思ったんですが、press shift # + なにか -> release なにか -> release shiftという手順でキー # 操作をすると最後のrelease shiftで反応してしまって意図通り # に動かないので、これは断念しました。 それから、いくつかモード拡張ができるようにしてみました。英大 文字2つ以上で云々というのも、パクろう^W実装しようかと思いま したが、とりあえず見送りました。 -- Akira TAGOH -------------- next part -------------- diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_action.cpp scim-anthy-1.0.0/src/scim_anthy_action.cpp --- scim-anthy-1.0.0.orig/src/scim_anthy_action.cpp 2006-02-08 12:14:01.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_action.cpp 2006-07-09 00:07:59.000000000 +0900 @@ -78,3 +78,9 @@ { return util_match_key_event (m_key_bindings, key, SCIM_KEY_CapsLockMask); } + +bool +Action::match_action_name (const char *name) +{ + return (m_name.compare (name) == 0); +} diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_action.h scim-anthy-1.0.0/src/scim_anthy_action.h --- scim-anthy-1.0.0.orig/src/scim_anthy_action.h 2006-02-08 12:14:01.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_action.h 2006-07-09 02:31:13.000000000 +0900 @@ -43,7 +43,8 @@ bool perform (AnthyInstance *performer); bool perform (AnthyInstance *performer, const KeyEvent &key); - + + bool match_action_name (const char *name); private: bool match_key_event (const KeyEvent &key); diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_factory.cpp scim-anthy-1.0.0/src/scim_anthy_factory.cpp --- scim-anthy-1.0.0.orig/src/scim_anthy_factory.cpp 2006-07-06 20:45:15.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_factory.cpp 2006-07-10 21:23:35.000000000 +0900 @@ -122,6 +122,7 @@ m_romaji_half_number (SCIM_ANTHY_CONFIG_ROMAJI_HALF_NUMBER_DEFAULT), m_romaji_allow_split (SCIM_ANTHY_CONFIG_ROMAJI_ALLOW_SPLIT_DEFAULT), m_romaji_pseudo_ascii_mode (SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_MODE_DEFAULT), + m_romaji_pseudo_ascii_blank_behavior (SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_BLANK_BEHAVIOR), m_nicola_time (SCIM_ANTHY_CONFIG_NICOLA_TIME_DEFAULT), m_dict_admin_command (SCIM_ANTHY_CONFIG_DICT_ADMIN_COMMAND_DEFAULT), m_add_word_command (SCIM_ANTHY_CONFIG_ADD_WORD_COMMAND_DEFAULT), @@ -327,7 +328,7 @@ #else #define APPEND_ACTION(key, func) \ { \ - String name = "func", str; \ + String name = #key, str; \ if (loaded) { \ String str2, str3; \ str2 = String (SCIM_ANTHY_CONFIG_##key##_KEY); \ @@ -414,6 +415,7 @@ ANTHY_DEFINE_ACTION (action_hiragana_mode); ANTHY_DEFINE_ACTION (action_katakana_mode); ANTHY_DEFINE_ACTION (action_half_katakana_mode); +ANTHY_DEFINE_ACTION (action_cancel_pseudo_ascii_mode); ANTHY_DEFINE_ACTION (action_launch_dict_admin_tool); ANTHY_DEFINE_ACTION (action_add_word); @@ -495,6 +497,10 @@ = config->read (String (SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_MODE), SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_MODE_DEFAULT); + m_romaji_pseudo_ascii_blank_behavior + = config->read (String (SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_BLANK_BEHAVIOR), + SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_BLANK_BEHAVIOR_DEFAULT); + m_nicola_time = config->read (String (SCIM_ANTHY_CONFIG_NICOLA_TIME), SCIM_ANTHY_CONFIG_NICOLA_TIME_DEFAULT); @@ -688,6 +694,7 @@ APPEND_ACTION (HIRAGANA_MODE, action_hiragana_mode); APPEND_ACTION (KATAKANA_MODE, action_katakana_mode); APPEND_ACTION (HALF_KATAKANA_MODE, action_half_katakana_mode); + APPEND_ACTION (CANCEL_PSEUDO_ASCII_MODE,action_cancel_pseudo_ascii_mode); // dict keys APPEND_ACTION (DICT_ADMIN, action_launch_dict_admin_tool); diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_factory.h scim-anthy-1.0.0/src/scim_anthy_factory.h --- scim-anthy-1.0.0.orig/src/scim_anthy_factory.h 2006-07-06 20:45:15.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_factory.h 2006-07-09 00:41:05.000000000 +0900 @@ -91,7 +91,10 @@ bool m_romaji_half_symbol; bool m_romaji_half_number; bool m_romaji_allow_split; + bool m_romaji_pseudo_ascii_mode; + bool m_romaji_pseudo_ascii_blank_behavior; + int m_nicola_time; KeyEventList m_left_thumb_keys; KeyEventList m_right_thumb_keys; diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_imengine.cpp scim-anthy-1.0.0/src/scim_anthy_imengine.cpp --- scim-anthy-1.0.0.orig/src/scim_anthy_imengine.cpp 2006-07-06 20:45:15.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_imengine.cpp 2006-07-10 21:21:00.000000000 +0900 @@ -194,9 +194,25 @@ bool AnthyInstance::process_key_event_lookup_keybind (const KeyEvent& key) { + std::vector<Action>::iterator it; + m_last_key = key; - std::vector<Action>::iterator it; + /* try to find a "insert a blank" action to be not stolen a blank key + * when entering the pseudo ascii mode. + */ + if (get_pseudo_ascii_mode () != 0 && + m_factory->m_romaji_pseudo_ascii_blank_behavior && + m_preedit.is_pseudo_ascii_mode ()) { + for (it = m_factory->m_actions.begin(); + it != m_factory->m_actions.end(); + it++) { + if (it->match_action_name ("INSERT_SPACE") && + it->perform (this, key)) { + return true; + } + } + } for (it = m_factory->m_actions.begin(); it != m_factory->m_actions.end(); it++) @@ -819,16 +835,14 @@ if (method != get_typing_method ()) { Key2KanaTable *fundamental_table = NULL; - bool pseudo_ascii = false; if (method == SCIM_ANTHY_TYPING_METHOD_ROMAJI) { fundamental_table = m_factory->m_custom_romaji_table; - pseudo_ascii = m_factory->m_romaji_pseudo_ascii_mode; } else if (method == SCIM_ANTHY_TYPING_METHOD_KANA) { fundamental_table = m_factory->m_custom_kana_table; } m_preedit.set_typing_method (method); - m_preedit.use_pseudo_ascii_mode (pseudo_ascii); + m_preedit.set_pseudo_ascii_mode (get_pseudo_ascii_mode ()); } } @@ -1115,10 +1129,11 @@ bool AnthyInstance::action_insert_space (void) { - if (m_preedit.is_preediting ()) - return false; + String str; + bool is_wide = false, retval = false; - bool is_wide = false; + if (m_preedit.is_preediting () && !m_factory->m_romaji_pseudo_ascii_blank_behavior) + return false; if (m_factory->m_space_type == "FollowMode") { InputMode mode = get_input_mode (); @@ -1134,17 +1149,28 @@ } if (is_wide) { - commit_string (utf8_mbstowcs ("\xE3\x80\x80")); - return true; + str = "\xE3\x80\x80"; + retval = true; } else if (get_typing_method () == SCIM_ANTHY_TYPING_METHOD_NICOLA || // FIXME! it's a ad-hoc solution. (m_last_key.code != SCIM_KEY_space && m_last_key.code != SCIM_KEY_KP_Space)) { - commit_string (utf8_mbstowcs (" ")); - return true; + str = " "; + retval = true; } - return false; + if (retval) { + if (m_preedit.is_pseudo_ascii_mode ()) { + m_preedit.append (m_last_key, str); + show_preedit_string (); + m_preedit_string_visible = true; + set_preedition (); + } else { + commit_string (utf8_mbstowcs (str)); + } + } + + return retval; } bool @@ -1775,6 +1801,14 @@ } bool +AnthyInstance::action_cancel_pseudo_ascii_mode (void) +{ + m_preedit.reset_pseudo_ascii_mode (); + + return true; +} + +bool AnthyInstance::convert_kana (CandidateType type) { if (!m_preedit.is_preediting ()) @@ -2182,22 +2216,15 @@ if (m_on_init || !m_factory->m_show_typing_method_label) { if (m_factory->m_typing_method == "NICOLA") { m_preedit.set_typing_method (SCIM_ANTHY_TYPING_METHOD_NICOLA); - m_preedit.use_pseudo_ascii_mode(false); } else if (m_factory->m_typing_method == "Kana") { m_preedit.set_typing_method (SCIM_ANTHY_TYPING_METHOD_KANA); - m_preedit.use_pseudo_ascii_mode(false); } else { m_preedit.set_typing_method (SCIM_ANTHY_TYPING_METHOD_ROMAJI); - m_preedit.use_pseudo_ascii_mode(m_factory->m_romaji_pseudo_ascii_mode); } + m_preedit.set_pseudo_ascii_mode (get_pseudo_ascii_mode ()); } else { - TypingMethod m = m_preedit.get_typing_method (); - - m_preedit.set_typing_method (m); - if (m == SCIM_ANTHY_TYPING_METHOD_ROMAJI) - m_preedit.use_pseudo_ascii_mode(m_factory->m_romaji_pseudo_ascii_mode); - else - m_preedit.use_pseudo_ascii_mode(false); + m_preedit.set_typing_method (get_typing_method ()); + m_preedit.set_pseudo_ascii_mode (get_pseudo_ascii_mode ()); } // set conversion mode @@ -2282,6 +2309,21 @@ else return false; } + +int +AnthyInstance::get_pseudo_ascii_mode (void) +{ + int retval = 0; + TypingMethod m = get_typing_method (); + + if (m == SCIM_ANTHY_TYPING_METHOD_ROMAJI) { + if (m_factory->m_romaji_pseudo_ascii_mode) + retval |= SCIM_ANTHY_PSEUDO_ASCII_TRIGGERED_CAPITALIZED; + } + + return retval; +} + /* vi:ts=4:nowrap:ai:expandtab */ diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_imengine.h scim-anthy-1.0.0/src/scim_anthy_imengine.h --- scim-anthy-1.0.0.orig/src/scim_anthy_imengine.h 2006-02-13 17:00:41.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_imengine.h 2006-07-10 21:22:08.000000000 +0900 @@ -184,6 +184,7 @@ bool action_hiragana_mode (void); bool action_katakana_mode (void); bool action_half_katakana_mode (void); + bool action_cancel_pseudo_ascii_mode (void); bool action_add_word (void); bool action_launch_dict_admin_tool (void); @@ -203,6 +204,7 @@ void *data = NULL, delete_func delete_fn = NULL); void timeout_remove (uint32 id); + int get_pseudo_ascii_mode (void); private: /* processing key event */ diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_kana.cpp scim-anthy-1.0.0/src/scim_anthy_kana.cpp --- scim-anthy-1.0.0.orig/src/scim_anthy_kana.cpp 2006-02-08 12:14:01.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_kana.cpp 2006-07-09 03:25:25.000000000 +0900 @@ -93,7 +93,8 @@ } bool -KanaConvertor::can_append (const KeyEvent & key) +KanaConvertor::can_append (const KeyEvent & key, + bool ignore_space) { // ignore key release. if (key.is_key_release ()) @@ -196,8 +197,17 @@ String s; s += key.get_ascii_code (); - result = utf8_mbstowcs (s); raw = s; + + return append (raw, result, pending); +} + +bool +KanaConvertor::append (const String & str, + WideString & result, + WideString & pending) +{ + result = utf8_mbstowcs (str); m_pending = String (); return false; diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_kana.h scim-anthy-1.0.0/src/scim_anthy_kana.h --- scim-anthy-1.0.0.orig/src/scim_anthy_kana.h 2006-02-08 12:14:01.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_kana.h 2006-07-09 03:27:48.000000000 +0900 @@ -40,11 +40,15 @@ KanaConvertor (AnthyInstance & anthy); virtual ~KanaConvertor (); - bool can_append (const KeyEvent & key); + bool can_append (const KeyEvent & key, + bool ignore_space = false); bool append (const KeyEvent & key, WideString & result, WideString & pending, String & raw); + bool append (const String & raw, + WideString & result, + WideString & pending); void clear (void); bool is_pending (void); diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_key2kana.cpp scim-anthy-1.0.0/src/scim_anthy_key2kana.cpp --- scim-anthy-1.0.0.orig/src/scim_anthy_key2kana.cpp 2006-07-06 20:45:15.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_key2kana.cpp 2006-07-10 23:42:05.000000000 +0900 @@ -32,7 +32,7 @@ m_is_in_pseudo_ascii_mode (false) { set_case_sensitive (false); - use_pseudo_ascii_mode (false); + set_pseudo_ascii_mode (0); } Key2KanaConvertor::~Key2KanaConvertor () @@ -40,7 +40,8 @@ } bool -Key2KanaConvertor::can_append (const KeyEvent & key) +Key2KanaConvertor::can_append (const KeyEvent & key, + bool ignore_space) { // ignore key release. if (key.is_key_release ()) @@ -53,7 +54,8 @@ return false; } - if (isprint(key.get_ascii_code ()) && !isspace(key.get_ascii_code ())) + if (isprint(key.get_ascii_code ()) && + (ignore_space || !isspace(key.get_ascii_code ()))) return true; if (util_key_is_keypad (key)) @@ -126,9 +128,7 @@ bool has_partial_match = false; bool retval = false; - if (m_pseudo_ascii_mode) - compute_for_pseudo_ascii_mode(widestr); - if (m_is_in_pseudo_ascii_mode) { + if (m_pseudo_ascii_mode != 0 && process_pseudo_ascii_mode (widestr)) { m_pending += widestr; pending = m_pending; return false; @@ -268,19 +268,26 @@ } } -void -Key2KanaConvertor::compute_for_pseudo_ascii_mode(const WideString & wstr) +bool +Key2KanaConvertor::process_pseudo_ascii_mode (const WideString & wstr) { - for (unsigned int i = 0; !m_is_in_pseudo_ascii_mode && i < wstr.length (); i++) { - if (wstr[i] >= 'A' && wstr[i] <= 'Z') + for (unsigned int i = 0; i < wstr.length (); i++) { + if ((wstr[i] >= 'A' && wstr[i] <= 'Z') || + iswspace(wstr[i])) { m_is_in_pseudo_ascii_mode = true; + } else if (wstr[i] >= 0x80) { + m_is_in_pseudo_ascii_mode = false; + } } + + return m_is_in_pseudo_ascii_mode; } void Key2KanaConvertor::reset_pseudo_ascii_mode (void) { m_is_in_pseudo_ascii_mode = false; + m_pending.clear(); } /* diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_key2kana.h scim-anthy-1.0.0/src/scim_anthy_key2kana.h --- scim-anthy-1.0.0.orig/src/scim_anthy_key2kana.h 2006-07-06 20:45:15.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_key2kana.h 2006-07-10 22:21:02.000000000 +0900 @@ -41,7 +41,8 @@ Key2KanaTableSet & tables); virtual ~Key2KanaConvertor (); - bool can_append (const KeyEvent & key); + bool can_append (const KeyEvent & key, + bool ignore_space = false); bool append (const KeyEvent & key, WideString & result, WideString & pending, @@ -53,9 +54,11 @@ WideString flush_pending (void); void reset_pending (const WideString & result, const String & raw); - void use_pseudo_ascii_mode (bool flag) - { m_pseudo_ascii_mode = flag; } - void compute_for_pseudo_ascii_mode (const WideString & wstr); + void set_pseudo_ascii_mode (int mode) + { m_pseudo_ascii_mode = mode; } + bool is_pseudo_ascii_mode (void) + { return m_is_in_pseudo_ascii_mode; } + bool process_pseudo_ascii_mode (const WideString & wstr); void reset_pseudo_ascii_mode (void); private: @@ -70,8 +73,9 @@ // state WideString m_pending; Key2KanaRule m_exact_match; - bool m_pseudo_ascii_mode; + int m_pseudo_ascii_mode; bool m_is_in_pseudo_ascii_mode; + bool m_reset_pseudo_ascii_mode; }; } diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_key2kana_base.h scim-anthy-1.0.0/src/scim_anthy_key2kana_base.h --- scim-anthy-1.0.0.orig/src/scim_anthy_key2kana_base.h 2006-07-06 20:45:15.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_key2kana_base.h 2006-07-10 21:48:24.000000000 +0900 @@ -36,11 +36,15 @@ {}; virtual ~Key2KanaConvertorBase () {}; - virtual bool can_append (const KeyEvent & key) = 0; + virtual bool can_append (const KeyEvent & key, + bool ignore_space = false) = 0; virtual bool append (const KeyEvent & key, WideString & result, WideString & pending, String & raw) = 0; + virtual bool append (const String & raw, + WideString & result, + WideString & pending) = 0; virtual void clear (void) = 0; virtual bool is_pending (void) = 0; @@ -51,7 +55,7 @@ virtual void reset_pseudo_ascii_mode (void) {} - virtual void compute_for_pseudo_ascii_mode (const WideString & wstr) + virtual bool process_pseudo_ascii_mode (const WideString & wstr) {} virtual void set_case_sensitive (bool sensitive) diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_nicola.cpp scim-anthy-1.0.0/src/scim_anthy_nicola.cpp --- scim-anthy-1.0.0.orig/src/scim_anthy_nicola.cpp 2006-02-08 12:14:01.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_nicola.cpp 2006-07-09 03:35:11.000000000 +0900 @@ -43,7 +43,8 @@ } bool -NicolaConvertor::can_append (const KeyEvent & key) +NicolaConvertor::can_append (const KeyEvent & key, + bool ignore_space) { if (key == m_through_key_event) { m_through_key_event = KeyEvent (); @@ -84,7 +85,7 @@ } if (isprint (key.get_ascii_code ()) && - !isspace (key.get_ascii_code ())) + (ignore_space || !isspace (key.get_ascii_code ()))) { return true; } @@ -583,6 +584,17 @@ return handle_voiced_consonant (result, pending); } +bool +NicolaConvertor::append (const String & str, + WideString & result, + WideString & pending) +{ + result = utf8_mbstowcs (str); + m_pending = WideString (); + + return false; +} + void NicolaConvertor::clear (void) { diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_nicola.h scim-anthy-1.0.0/src/scim_anthy_nicola.h --- scim-anthy-1.0.0.orig/src/scim_anthy_nicola.h 2006-02-08 12:14:01.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_nicola.h 2006-07-09 03:28:30.000000000 +0900 @@ -48,11 +48,15 @@ Key2KanaTableSet & tables); virtual ~NicolaConvertor (); - bool can_append (const KeyEvent & key); + bool can_append (const KeyEvent & key, + bool ignore_space = false); bool append (const KeyEvent & key, WideString & result, WideString & pending, String & raw); + bool append (const String & raw, + WideString & result, + WideString & pending); void clear (void); bool is_pending (void); diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_preedit.cpp scim-anthy-1.0.0/src/scim_anthy_preedit.cpp --- scim-anthy-1.0.0.orig/src/scim_anthy_preedit.cpp 2006-07-06 20:45:15.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_preedit.cpp 2006-07-10 21:25:10.000000000 +0900 @@ -191,6 +191,13 @@ return retval; } +bool +Preedit::append (const KeyEvent & key, + const String & string) +{ + return m_reading.append (key, string); +} + void Preedit::erase (bool backward) { @@ -477,9 +484,21 @@ } void -Preedit::use_pseudo_ascii_mode (bool flag) +Preedit::set_pseudo_ascii_mode (int mode) +{ + m_reading.set_pseudo_ascii_mode (mode); +} + +bool +Preedit::is_pseudo_ascii_mode (void) +{ + return m_reading.is_pseudo_ascii_mode (); +} + +void +Preedit::reset_pseudo_ascii_mode (void) { - m_reading.use_pseudo_ascii_mode (flag); + m_reading.reset_pseudo_ascii_mode (); } bool diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_preedit.h scim-anthy-1.0.0/src/scim_anthy_preedit.h --- scim-anthy-1.0.0.orig/src/scim_anthy_preedit.h 2006-07-06 20:45:15.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_preedit.h 2006-07-10 21:25:30.000000000 +0900 @@ -29,6 +29,9 @@ #include "scim_anthy_reading.h" #include "scim_anthy_conversion.h" +#define SCIM_ANTHY_PSEUDO_ASCII_TRIGGERED_CAPITALIZED (1 << 0) +#define SCIM_ANTHY_PSEUDO_ASCII_TRIGGERED_COUPLE_OF_CAPITAL (1 << 1) + using namespace scim; class AnthyInstance; @@ -64,6 +67,8 @@ virtual bool can_process_key_event (const KeyEvent & key); // return true if commiting is needed. virtual bool process_key_event (const KeyEvent & key); + virtual bool append (const KeyEvent & key, + const String & string); virtual void erase (bool backward = true); virtual void finish (void); @@ -121,7 +126,9 @@ virtual bool get_symbol_width (void); virtual void set_number_width (bool half); virtual bool get_number_width (void); - virtual void use_pseudo_ascii_mode (bool flag); + virtual void set_pseudo_ascii_mode (int mode); + virtual bool is_pseudo_ascii_mode (void); + virtual void reset_pseudo_ascii_mode(void); private: void get_reading_substr (WideString & substr, diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_prefs.cpp scim-anthy-1.0.0/src/scim_anthy_prefs.cpp --- scim-anthy-1.0.0.orig/src/scim_anthy_prefs.cpp 2006-07-06 20:45:15.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_prefs.cpp 2006-07-10 21:17:21.000000000 +0900 @@ -102,7 +102,16 @@ SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_MODE_DEFAULT, N_("_Entering the pseudo ASCII input mode with capital letters."), NULL, - N_("If this check is enabled, capital letters will becomes a trigger to enter the pseudo ASCII input mode during capital letters are in preedit."), + N_("If this check is enabled, capital letters will becomes a trigger to enter the pseudo ASCII input mode."), + false, + }, + { + SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_BLANK_BEHAVIOR, + SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_BLANK_BEHAVIOR_DEFAULT, + SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_BLANK_BEHAVIOR_DEFAULT, + N_("Insert a blank with a blank key."), + NULL, + N_("If this check is enabled, a blank key will works to insert a blank when entering the pseudo ASCII input mode."), false, }, { @@ -547,6 +556,16 @@ false, }, { + SCIM_ANTHY_CONFIG_CANCEL_PSEUDO_ASCII_MODE_KEY, + SCIM_ANTHY_CONFIG_CANCEL_PSEUDO_ASCII_MODE_KEY_DEFAULT, + SCIM_ANTHY_CONFIG_CANCEL_PSEUDO_ASCII_MODE_KEY_DEFAULT, + N_("pseudo ASCII mode cancel key"), + N_("Select pseudo ASCII mode cancel key"), + N_("The key events to cancel the pseudo ASCII mode."), + NULL, + false, + }, + { SCIM_ANTHY_CONFIG_CIRCLE_TYPING_METHOD_KEY, SCIM_ANTHY_CONFIG_CIRCLE_TYPING_METHOD_KEY_DEFAULT, SCIM_ANTHY_CONFIG_CIRCLE_TYPING_METHOD_KEY_DEFAULT, @@ -1232,4 +1251,65 @@ false, }, }; + +BoolConfigData * +find_bool_config_entry (const char *config_key) +{ + if (!config_key) + return NULL; + + for (unsigned int i = 0; config_bool_common[i].key; i++) { + BoolConfigData *entry = &config_bool_common[i]; + if (entry->key && !strcmp (entry->key, config_key)) + return entry; + } + + return NULL; +} + +IntConfigData * +find_int_config_entry (const char *config_key) +{ + if (!config_key) + return NULL; + + for (unsigned int i = 0; config_int_common[i].key; i++) { + IntConfigData *entry = &config_int_common[i]; + if (entry->key && !strcmp (entry->key, config_key)) + return entry; + } + + return NULL; +} + +StringConfigData * +find_string_config_entry (const char *config_key) +{ + if (!config_key) + return NULL; + + for (unsigned int i = 0; config_string_common[i].key; i++) { + StringConfigData *entry = &config_string_common[i]; + if (entry->key && !strcmp (entry->key, config_key)) + return entry; + } + + return NULL; +} + +ColorConfigData * +find_color_config_entry (const char *config_key) +{ + if (!config_key) + return NULL; + + for (unsigned int i = 0; config_color_common[i].fg_key; i++) { + ColorConfigData *entry = &config_color_common[i]; + if (entry->fg_key && !strcmp (entry->fg_key, config_key)) + return entry; + } + + return NULL; +} + } diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_prefs.h scim-anthy-1.0.0/src/scim_anthy_prefs.h --- scim-anthy-1.0.0.orig/src/scim_anthy_prefs.h 2006-07-06 20:45:15.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_prefs.h 2006-07-10 23:46:52.000000000 +0900 @@ -36,6 +36,7 @@ #define SCIM_ANTHY_CONFIG_ROMAJI_HALF_NUMBER "/IMEngine/Anthy/RomajiHalfNumber" #define SCIM_ANTHY_CONFIG_ROMAJI_ALLOW_SPLIT "/IMEngine/Anthy/RomajiAllowSplit" #define SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_MODE "/IMEngine/Anthy/RomajiPseudoAsciiMode" +#define SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_BLANK_BEHAVIOR "/IMEngine/Anthy/RomajiPseudoAsciiBlankBehavior" #define SCIM_ANTHY_CONFIG_KANA_LAYOUT_FILE "/IMEngine/Anthy/KanaLayoutFile" @@ -81,6 +82,7 @@ #define SCIM_ANTHY_CONFIG_HIRAGANA_MODE_KEY "/IMEngine/Anthy/HiraganaModeKey" #define SCIM_ANTHY_CONFIG_KATAKANA_MODE_KEY "/IMEngine/Anthy/KatakanaModeKey" #define SCIM_ANTHY_CONFIG_HALF_KATAKANA_MODE_KEY "/IMEngine/Anthy/HalfKatakanaModeKey" +#define SCIM_ANTHY_CONFIG_CANCEL_PSEUDO_ASCII_MODE_KEY "/IMEngine/Anthy/CancelPseudoAsciiModeKey" #define SCIM_ANTHY_CONFIG_INSERT_SPACE_KEY "/IMEngine/Anthy/InsertSpaceKey" #define SCIM_ANTHY_CONFIG_INSERT_ALT_SPACE_KEY "/IMEngine/Anthy/InsertAltSpaceKey" @@ -169,6 +171,7 @@ #define SCIM_ANTHY_CONFIG_ROMAJI_HALF_NUMBER_DEFAULT false #define SCIM_ANTHY_CONFIG_ROMAJI_ALLOW_SPLIT_DEFAULT true #define SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_MODE_DEFAULT true +#define SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_BLANK_BEHAVIOR_DEFAULT true #define SCIM_ANTHY_CONFIG_KANA_LAYOUT_FILE_DEFAULT "" @@ -214,6 +217,7 @@ #define SCIM_ANTHY_CONFIG_HIRAGANA_MODE_KEY_DEFAULT "" #define SCIM_ANTHY_CONFIG_KATAKANA_MODE_KEY_DEFAULT "" #define SCIM_ANTHY_CONFIG_HALF_KATAKANA_MODE_KEY_DEFAULT "" +#define SCIM_ANTHY_CONFIG_CANCEL_PSEUDO_ASCII_MODE_KEY_DEFAULT "" #define SCIM_ANTHY_CONFIG_INSERT_SPACE_KEY_DEFAULT "space" #define SCIM_ANTHY_CONFIG_INSERT_ALT_SPACE_KEY_DEFAULT "Shift+space" @@ -364,6 +368,11 @@ extern StringConfigData config_keyboards_dict []; extern ColorConfigData config_color_common []; +BoolConfigData *find_bool_config_entry (const char *config_key); +IntConfigData *find_int_config_entry (const char *config_key); +StringConfigData *find_string_config_entry (const char *config_key); +ColorConfigData *find_color_config_entry (const char *config_key); + } #endif /* SCIM_ANTHY_USE_GTK */ diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_reading.cpp scim-anthy-1.0.0/src/scim_anthy_reading.cpp --- scim-anthy-1.0.0.orig/src/scim_anthy_reading.cpp 2006-07-06 20:45:15.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_reading.cpp 2006-07-10 23:41:55.000000000 +0900 @@ -330,6 +330,71 @@ } } +bool +Reading::append (const KeyEvent & key, + const String & string) +{ + bool was_pending; + WideString result, pending; + bool need_commiting; + + if (!m_kana.can_append (key, true) && + !m_key2kana->can_append (key, true)) + return false; + + if (m_caret_offset != 0) { + split_segment (m_segment_pos); + reset_pending (); + } + + if (m_kana.can_append (key)) + was_pending = m_kana.is_pending (); + else + was_pending = m_key2kana->is_pending (); + + if (m_kana.can_append (key)) + need_commiting = m_kana.append (string, result, pending); + else + need_commiting = m_key2kana->append (string, result, pending); + + ReadingSegments::iterator begin = m_segments.begin (); + + // fix previous segment and prepare next segment if needed + if (!result.empty () || !pending.empty ()) { + if (!was_pending || // previous segment was already fixed + need_commiting) // previous segment has been fixed + { + ReadingSegment c; + m_segments.insert (begin + m_segment_pos, c); + m_segment_pos++; + } + } + + // fill segment + if (result.length() > 0 && pending.length () > 0) { + m_segments[m_segment_pos - 1].kana = result; + + ReadingSegment c; + c.raw += string; + c.kana = pending; + m_segments.insert (begin + m_segment_pos, c); + m_segment_pos++; + + } else if (result.length () > 0) { + m_segments[m_segment_pos - 1].raw += string; + m_segments[m_segment_pos - 1].kana = result; + + } else if (pending.length () > 0) { + m_segments[m_segment_pos - 1].raw += string; + m_segments[m_segment_pos - 1].kana = pending; + + } else { + + } + + return false; +} + void Reading::erase (unsigned int start, int len, bool allow_split) { @@ -433,7 +498,7 @@ m_segments[m_segment_pos - 1].raw); m_key2kana->reset_pseudo_ascii_mode(); for (unsigned int i = 0; i < m_segment_pos; i++) - m_key2kana->compute_for_pseudo_ascii_mode(m_segments[i].kana); + m_key2kana->process_pseudo_ascii_mode(m_segments[i].kana); } unsigned int @@ -655,7 +720,28 @@ } void -Reading::use_pseudo_ascii_mode (bool flag) +Reading::set_pseudo_ascii_mode (int mode) { - m_key2kana_normal.use_pseudo_ascii_mode (flag); + m_key2kana_normal.set_pseudo_ascii_mode (mode); +} + +bool +Reading::is_pseudo_ascii_mode (void) +{ + return m_key2kana_normal.is_pseudo_ascii_mode (); +} + +void +Reading::reset_pseudo_ascii_mode (void) +{ + if (m_key2kana_normal.is_pseudo_ascii_mode () && + m_key2kana_normal.is_pending ()) { + ReadingSegment c; + ReadingSegments::iterator it = m_segments.begin (); + + /* separate to another segment */ + m_key2kana_normal.reset_pseudo_ascii_mode (); + m_segments.insert (it + m_segment_pos, c); + m_segment_pos++; + } } diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_reading.h scim-anthy-1.0.0/src/scim_anthy_reading.h --- scim-anthy-1.0.0.orig/src/scim_anthy_reading.h 2006-07-06 20:45:15.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_reading.h 2006-07-10 21:26:36.000000000 +0900 @@ -80,6 +80,8 @@ = SCIM_ANTHY_STRING_HIRAGANA); String get_raw (unsigned int start = 0, int length = -1); + bool append (const KeyEvent & key, + const String & string); void erase (unsigned int start = 0, int length = -1, bool allow_split = false); @@ -104,7 +106,9 @@ bool get_symbol_width (void); void set_number_width (bool half); bool get_number_width (void); - void use_pseudo_ascii_mode (bool flag); + void set_pseudo_ascii_mode (int mode); + bool is_pseudo_ascii_mode (void); + void reset_pseudo_ascii_mode (void); private: void reset_pending (void); diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_setup.cpp scim-anthy-1.0.0/src/scim_anthy_setup.cpp --- scim-anthy-1.0.0.orig/src/scim_anthy_setup.cpp 2006-02-14 12:56:36.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_setup.cpp 2006-07-07 18:59:00.000000000 +0900 @@ -321,51 +321,6 @@ gpointer user_data); -static BoolConfigData * -find_bool_config_entry (const char *config_key) -{ - if (!config_key) - return NULL; - - for (unsigned int i = 0; config_bool_common[i].key; i++) { - BoolConfigData *entry = &config_bool_common[i]; - if (entry->key && !strcmp (entry->key, config_key)) - return entry; - } - - return NULL; -} - -static IntConfigData * -find_int_config_entry (const char *config_key) -{ - if (!config_key) - return NULL; - - for (unsigned int i = 0; config_int_common[i].key; i++) { - IntConfigData *entry = &config_int_common[i]; - if (entry->key && !strcmp (entry->key, config_key)) - return entry; - } - - return NULL; -} - -static StringConfigData * -find_string_config_entry (const char *config_key) -{ - if (!config_key) - return NULL; - - for (unsigned int i = 0; config_string_common[i].key; i++) { - StringConfigData *entry = &config_string_common[i]; - if (entry->key && !strcmp (entry->key, config_key)) - return entry; - } - - return NULL; -} - static StringConfigData * find_key_config_entry (const char *config_key) { @@ -380,21 +335,6 @@ return NULL; } -static ColorConfigData * -find_color_config_entry (const char *config_key) -{ - if (!config_key) - return NULL; - - for (unsigned int i = 0; config_color_common[i].fg_key; i++) { - ColorConfigData *entry = &config_color_common[i]; - if (entry->fg_key && !strcmp (entry->fg_key, config_key)) - return entry; - } - - return NULL; -} - GtkWidget * create_check_button (const char *config_key) { diff -ruN -x '*o' -x '*a' -x '*i' -x '*~' scim-anthy-1.0.0.orig/src/scim_anthy_setup_romaji.cpp scim-anthy-1.0.0/src/scim_anthy_setup_romaji.cpp --- scim-anthy-1.0.0.orig/src/scim_anthy_setup_romaji.cpp 2006-07-06 20:45:15.000000000 +0900 +++ scim-anthy-1.0.0/src/scim_anthy_setup_romaji.cpp 2006-07-07 18:38:05.000000000 +0900 @@ -60,23 +60,25 @@ static bool load_romaji_theme (void); -static void on_romaji_theme_menu_changed (GtkOptionMenu *omenu, - gpointer user_data); -static void on_romaji_customize_button_clicked(GtkWidget *button, - gpointer data); -static void on_table_editor_add_entry (ScimAnthyTableEditor *editor, - gpointer data); -static void on_table_editor_added_entry (ScimAnthyTableEditor *editor, - gpointer data); -static void on_table_editor_remove_entry (ScimAnthyTableEditor *editor, - gpointer data); -static void on_table_editor_removed_entry (ScimAnthyTableEditor *editor, - gpointer data); +static void on_romaji_pseudo_ascii_mode_toggled(GtkToggleButton *togglebutton, + gpointer user_data); +static void on_romaji_theme_menu_changed (GtkOptionMenu *omenu, + gpointer user_data); +static void on_romaji_customize_button_clicked (GtkWidget *button, + gpointer data); +static void on_table_editor_add_entry (ScimAnthyTableEditor *editor, + gpointer data); +static void on_table_editor_added_entry (ScimAnthyTableEditor *editor, + gpointer data); +static void on_table_editor_remove_entry (ScimAnthyTableEditor *editor, + gpointer data); +static void on_table_editor_removed_entry (ScimAnthyTableEditor *editor, + gpointer data); GtkWidget * romaji_page_create_ui (void) { - GtkWidget *vbox, *widget; + GtkWidget *vbox, *widget, *hbox, *label; vbox = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox); @@ -95,15 +97,31 @@ /* pseudo ascii mode */ widget = create_check_button (SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_MODE); + g_signal_connect ((gpointer) widget, "toggled", + G_CALLBACK (on_romaji_pseudo_ascii_mode_toggled), + NULL); gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 4); + /* pseudo ascii: blank behavior */ + hbox = gtk_hbox_new (FALSE, 0), *label; + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 4); + gtk_widget_show (hbox); + label = gtk_label_new (" "); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); + + widget = create_check_button (SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_BLANK_BEHAVIOR); + gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0); + // set initial state + on_romaji_pseudo_ascii_mode_toggled (GTK_TOGGLE_BUTTON (widget), NULL); + /* romaji table */ - GtkWidget *hbox = gtk_hbox_new (FALSE, 0); + hbox = gtk_hbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); - GtkWidget *label = gtk_label_new_with_mnemonic (_("Romaji _table:")); + label = gtk_label_new_with_mnemonic (_("Romaji _table:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2); gtk_widget_show (label); @@ -407,6 +425,18 @@ } static void +on_romaji_pseudo_ascii_mode_toggled (GtkToggleButton *togglebutton, + gpointer user_data) +{ + gboolean active = gtk_toggle_button_get_active (togglebutton); + BoolConfigData *entry; + + entry = find_bool_config_entry (SCIM_ANTHY_CONFIG_ROMAJI_PSEUDO_ASCII_BLANK_BEHAVIOR); + if (entry->widget) + gtk_widget_set_sensitive (GTK_WIDGET (entry->widget), active); +} + +static void on_romaji_theme_menu_changed (GtkOptionMenu *omenu, gpointer user_data) { bool success; -------------- next part -------------- テキスト形式以外の添付ファイルを保管しました... ファイル名: 無し 型: application/pgp-signature サイズ: 189 バイト 説明: 無し ダウンロード