diff options
author | Peng Wu <alexepico@gmail.com> | 2015-06-25 14:38:39 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2015-06-25 14:38:39 +0800 |
commit | 9ccc6d6c23bcfd0745cdb196d5eb2609beb3f4d5 (patch) | |
tree | 64a05e21b1f078717a53e3645fc4f31ead692ce4 /src | |
parent | 378473e32fb9cbb61a327ae7c67cbaf36a5c40e2 (diff) | |
download | ibus-libzhuyin-9ccc6d6c23bcfd0745cdb196d5eb2609beb3f4d5.tar.gz ibus-libzhuyin-9ccc6d6c23bcfd0745cdb196d5eb2609beb3f4d5.tar.xz ibus-libzhuyin-9ccc6d6c23bcfd0745cdb196d5eb2609beb3f4d5.zip |
fixes updateZhuyin again
Diffstat (limited to 'src')
-rw-r--r-- | src/ZYZPinyinEditor.cc | 2 | ||||
-rw-r--r-- | src/ZYZZhuyinEditor.cc | 46 |
2 files changed, 36 insertions, 12 deletions
diff --git a/src/ZYZPinyinEditor.cc b/src/ZYZPinyinEditor.cc index a3683a8..375848e 100644 --- a/src/ZYZPinyinEditor.cc +++ b/src/ZYZPinyinEditor.cc @@ -63,6 +63,8 @@ PinyinEditor::commit (void) void PinyinEditor::reset (void) { + m_preedit_text = ""; + PhoneticEditor::reset (); } diff --git a/src/ZYZZhuyinEditor.cc b/src/ZYZZhuyinEditor.cc index a0f004c..2590aac 100644 --- a/src/ZYZZhuyinEditor.cc +++ b/src/ZYZZhuyinEditor.cc @@ -62,12 +62,15 @@ ZhuyinEditor::commit (void) void ZhuyinEditor::reset (void) { + m_preedit_text = ""; + PhoneticEditor::reset (); } void ZhuyinEditor::updateZhuyin (void) { + static const char * tones[] = {" ", "ˊ", "ˇ", "ˋ", "˙", NULL}; const String & enhanced_text = m_text; resizeInstances (); @@ -87,19 +90,38 @@ ZhuyinEditor::updateZhuyin (void) (instance, section.c_str ()); zhuyin_guess_sentence (instance); - /* check whether the last character is space, + /* check whether the last character is tone, if not part of parsed chewing input, - turn the space into symbol. */ - if (end_pos == m_text.size () && - ' ' == section[section.size () - 1] && - section.size () > len) { - size_t length = get_enhanced_text_length (m_text); - erase_input_sequence (m_text, length - 1, 1); - insert_symbol (m_text, length - 1, BUILTIN_SYMBOL_TYPE, - "", " "); - /* as we changed the last space character, - reached the end of user input, exit the loop. */ - break; + turn the tone into symbol. */ + if (end_pos == m_text.size ()) { + + /* check tone symbol. */ + const char tone = section[section.size () - 1]; + gchar ** symbols = NULL; + zhuyin_in_chewing_keyboard (instance, tone, &symbols); + + gboolean is_tone = FALSE; + /* TODO: use g_strv_contains in future. */ + if (1 == g_strv_length (symbols)) { + for (const char ** strs = tones; *strs != NULL; ++strs) { + if (g_str_equal (*strs, symbols[0])) { + is_tone = TRUE; + break; + } + } + } + + if (is_tone && section.size () > len) { + size_t length = get_enhanced_text_length (m_text); + erase_input_sequence (m_text, length - 1, 1); + insert_symbol (m_text, length - 1, BUILTIN_SYMBOL_TYPE, + "", symbols[0]); + /* as we changed the last space character, + reached the end of user input, exit the loop. */ + g_strfreev (symbols); + break; + } + g_strfreev (symbols); } ++index; |