diff options
author | Peng Wu <alexepico@gmail.com> | 2014-07-14 13:00:48 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2014-07-14 13:00:48 +0800 |
commit | d4b7aa31a0261af21c8cdf36717119175280ca76 (patch) | |
tree | e0c062b40c865df3cc23696f3ffd63a8fe439858 | |
parent | 0de259f2382df739af096ac07728ec7a2dd2b6ae (diff) | |
download | ibus-libzhuyin-d4b7aa31a0261af21c8cdf36717119175280ca76.tar.gz ibus-libzhuyin-d4b7aa31a0261af21c8cdf36717119175280ca76.tar.xz ibus-libzhuyin-d4b7aa31a0261af21c8cdf36717119175280ca76.zip |
fixes method selectCandidate
-rw-r--r-- | src/ZYZBopomofoSymbolSection.cc | 3 | ||||
-rw-r--r-- | src/ZYZBuiltinSymbolSection.cc | 3 | ||||
-rw-r--r-- | src/ZYZPhoneticEditor.cc | 6 | ||||
-rw-r--r-- | src/ZYZPhoneticSection.cc | 7 | ||||
-rw-r--r-- | src/ZYZPinyinEditor.cc | 1 | ||||
-rw-r--r-- | src/ZYZZhuyinEditor.cc | 1 |
6 files changed, 20 insertions, 1 deletions
diff --git a/src/ZYZBopomofoSymbolSection.cc b/src/ZYZBopomofoSymbolSection.cc index a12093b..1628973 100644 --- a/src/ZYZBopomofoSymbolSection.cc +++ b/src/ZYZBopomofoSymbolSection.cc @@ -90,6 +90,9 @@ BopomofoSymbolSection::fillLookupTableByPage () int BopomofoSymbolSection::selectCandidate (guint index) { + if (index >= m_candidates.size ()) + return 0; + m_choice = m_candidates[index]; return 1; } diff --git a/src/ZYZBuiltinSymbolSection.cc b/src/ZYZBuiltinSymbolSection.cc index 2472604..5f203ac 100644 --- a/src/ZYZBuiltinSymbolSection.cc +++ b/src/ZYZBuiltinSymbolSection.cc @@ -89,6 +89,9 @@ BuiltinSymbolSection::fillLookupTableByPage () int BuiltinSymbolSection::selectCandidate (guint index) { + if (index >= m_candidates.size ()) + return 0; + m_choice = m_candidates[index]; return 1; } diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc index ccdf51f..f6217a2 100644 --- a/src/ZYZPhoneticEditor.cc +++ b/src/ZYZPhoneticEditor.cc @@ -408,6 +408,9 @@ PhoneticEditor::selectCandidate (guint index) if (STATE_CANDIDATE_SHOWN == m_input_state) { int offset = m_phonetic_section->selectCandidate (index); + if (0 == offset) + return FALSE; + m_cursor += offset; m_input_state = STATE_INPUT; @@ -424,6 +427,9 @@ PhoneticEditor::selectCandidate (guint index) int offset = symbols->selectCandidate (index); + if (0 == offset) + return FALSE; + erase_input_sequence (m_text, m_cursor, 1); insert_symbol (m_text, m_cursor, symbols->m_type, symbols->m_lookup, symbols->m_choice); diff --git a/src/ZYZPhoneticSection.cc b/src/ZYZPhoneticSection.cc index a240a68..99d6213 100644 --- a/src/ZYZPhoneticSection.cc +++ b/src/ZYZPhoneticSection.cc @@ -101,6 +101,12 @@ PhoneticSection::selectCandidate (guint index) guint16 prev_pos = m_cursor, cur_pos = 0; ChewingKeyRest * key_rest = NULL; + guint len = 0; + zhuyin_get_n_candidate (m_instance, &len); + + if (index >= len) + return 0; + lookup_candidate_t * candidate = NULL; zhuyin_get_candidate (m_instance, index, &candidate); @@ -111,7 +117,6 @@ PhoneticSection::selectCandidate (guint index) offset = zhuyin_choose_candidate (m_instance, offset, candidate); - guint len = 0; zhuyin_get_n_zhuyin (m_instance, &len); if (offset < len) { diff --git a/src/ZYZPinyinEditor.cc b/src/ZYZPinyinEditor.cc index 6a6ba89..7eb85e9 100644 --- a/src/ZYZPinyinEditor.cc +++ b/src/ZYZPinyinEditor.cc @@ -154,6 +154,7 @@ PinyinEditor::updatePreeditText (void) start_pos = end_pos; } + m_buffer.clear (); if (m_props.modeTrad ()) { m_buffer = m_preedit_text; } else { diff --git a/src/ZYZZhuyinEditor.cc b/src/ZYZZhuyinEditor.cc index df02ce2..50ff322 100644 --- a/src/ZYZZhuyinEditor.cc +++ b/src/ZYZZhuyinEditor.cc @@ -159,6 +159,7 @@ ZhuyinEditor::updatePreeditText (void) start_pos = end_pos; } + m_buffer.clear (); if (m_props.modeTrad ()) { m_buffer = m_preedit_text; } else { |