diff options
author | Peng Wu <alexepico@gmail.com> | 2015-08-05 15:22:04 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2015-08-05 15:22:04 +0800 |
commit | d8871f3ab4ec70bf58a26eab6e6f948abb5417ec (patch) | |
tree | d97da0ceda2ce4a959abb855d1ab159cc35d7196 /src | |
parent | e92adcdef3188bd879d579fd4b6c3996dee52ef8 (diff) | |
download | ibus-libzhuyin-d8871f3ab4ec70bf58a26eab6e6f948abb5417ec.tar.gz ibus-libzhuyin-d8871f3ab4ec70bf58a26eab6e6f948abb5417ec.tar.xz ibus-libzhuyin-d8871f3ab4ec70bf58a26eab6e6f948abb5417ec.zip |
update updateZhuyin method
Diffstat (limited to 'src')
-rw-r--r-- | src/ZYZPinyinEditor.cc | 8 | ||||
-rw-r--r-- | src/ZYZZhuyinEditor.cc | 16 |
2 files changed, 21 insertions, 3 deletions
diff --git a/src/ZYZPinyinEditor.cc b/src/ZYZPinyinEditor.cc index debc2e5..aa81602 100644 --- a/src/ZYZPinyinEditor.cc +++ b/src/ZYZPinyinEditor.cc @@ -72,6 +72,8 @@ void PinyinEditor::updateZhuyin (void) { const String & enhanced_text = m_text; + String new_text; + size_t append_offset = 0; resizeInstances (); @@ -89,6 +91,9 @@ PinyinEditor::updateZhuyin (void) zhuyin_parse_more_full_pinyins (instance, section.c_str ()); zhuyin_guess_sentence (instance); + new_text += section; + append_offset += section.length (); + ++index; } @@ -97,11 +102,14 @@ PinyinEditor::updateZhuyin (void) get_symbol_section (enhanced_text, start_pos, end_pos, type, lookup, choice); + insert_symbol (new_text, append_offset, type, lookup, choice); + append_offset ++; } start_pos = end_pos; } + m_text = new_text; return; } diff --git a/src/ZYZZhuyinEditor.cc b/src/ZYZZhuyinEditor.cc index bae909e..b237849 100644 --- a/src/ZYZZhuyinEditor.cc +++ b/src/ZYZZhuyinEditor.cc @@ -71,7 +71,10 @@ void ZhuyinEditor::updateZhuyin (void) { static const char * tones[] = {" ", "ˊ", "ˇ", "ˋ", "˙", NULL}; + const String & enhanced_text = m_text; + String new_text; + size_t append_offset = 0; resizeInstances (); @@ -90,6 +93,9 @@ ZhuyinEditor::updateZhuyin (void) (instance, section.c_str ()); zhuyin_guess_sentence (instance); + new_text += section; + append_offset += section.length (); + /* check whether the last character is tone, if not part of parsed chewing input, turn the tone into symbol. */ @@ -112,9 +118,9 @@ ZhuyinEditor::updateZhuyin (void) } 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, + erase_input_sequence (new_text, append_offset - 1, 1); + insert_symbol (new_text, append_offset - 1, + BUILTIN_SYMBOL_TYPE, "", symbols[0]); /* as we changed the last space character, reached the end of user input, exit the loop. */ @@ -131,11 +137,15 @@ ZhuyinEditor::updateZhuyin (void) String type, lookup, choice; get_symbol_section (enhanced_text, start_pos, end_pos, type, lookup, choice); + + insert_symbol (new_text, append_offset, type, lookup, choice); + append_offset ++; } start_pos = end_pos; } + m_text = new_text; return; } |