diff options
author | Peng Wu <alexepico@gmail.com> | 2015-08-05 17:03:03 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2015-08-05 17:03:03 +0800 |
commit | 828fa4586307d0886b714aad01ae99512ed9dcdf (patch) | |
tree | eb4ed564418a7dd418e66ca97c12b0f1d53163a3 /src | |
parent | d8871f3ab4ec70bf58a26eab6e6f948abb5417ec (diff) | |
download | ibus-libzhuyin-828fa4586307d0886b714aad01ae99512ed9dcdf.tar.gz ibus-libzhuyin-828fa4586307d0886b714aad01ae99512ed9dcdf.tar.xz ibus-libzhuyin-828fa4586307d0886b714aad01ae99512ed9dcdf.zip |
update updateZhuyin method
Diffstat (limited to 'src')
-rw-r--r-- | src/ZYZPinyinEditor.cc | 15 | ||||
-rw-r--r-- | src/ZYZZhuyinEditor.cc | 12 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/ZYZPinyinEditor.cc b/src/ZYZPinyinEditor.cc index aa81602..4d7abe0 100644 --- a/src/ZYZPinyinEditor.cc +++ b/src/ZYZPinyinEditor.cc @@ -88,7 +88,20 @@ PinyinEditor::updateZhuyin (void) get_phonetic_section (enhanced_text, start_pos, end_pos, section); zhuyin_instance_t * instance = m_instances[index]; - zhuyin_parse_more_full_pinyins (instance, section.c_str ()); + size_t len = zhuyin_parse_more_full_pinyins + (instance, section.c_str ()); + bool valid = zhuyin_valid_zhuyin_keys (instance); + if (!valid) { + size_t valid_len = zhuyin_get_parsed_input_length (instance); + + const gchar * str = NULL; + zhuyin_get_raw_user_input (instance, &str); + section = str; + + /* hack here: usually only one zhuyin key will have problem, + so it is safe to just move the cursor. */ + m_cursor -= len - valid_len; + } zhuyin_guess_sentence (instance); new_text += section; diff --git a/src/ZYZZhuyinEditor.cc b/src/ZYZZhuyinEditor.cc index b237849..a6aa8dd 100644 --- a/src/ZYZZhuyinEditor.cc +++ b/src/ZYZZhuyinEditor.cc @@ -91,6 +91,18 @@ ZhuyinEditor::updateZhuyin (void) zhuyin_instance_t * instance = m_instances[index]; size_t len = zhuyin_parse_more_chewings (instance, section.c_str ()); + bool valid = zhuyin_valid_zhuyin_keys (instance); + if (!valid) { + size_t valid_len = zhuyin_get_parsed_input_length (instance); + + const gchar * str = NULL; + zhuyin_get_raw_user_input (instance, &str); + section = str; + + /* hack here: usually only one zhuyin key will have problem, + so it is safe to just move the cursor. */ + m_cursor -= len - valid_len; + } zhuyin_guess_sentence (instance); new_text += section; |