diff options
author | Peng Wu <alexepico@gmail.com> | 2015-08-04 15:36:42 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2015-08-04 15:36:42 +0800 |
commit | e92adcdef3188bd879d579fd4b6c3996dee52ef8 (patch) | |
tree | 233e7edda56ec3af115284bd71f62b323b0f914c | |
parent | 90f9778f74556d3e09adfa3559a04d8902a68ad1 (diff) | |
download | ibus-libzhuyin-e92adcdef3188bd879d579fd4b6c3996dee52ef8.tar.gz ibus-libzhuyin-e92adcdef3188bd879d579fd4b6c3996dee52ef8.tar.xz ibus-libzhuyin-e92adcdef3188bd879d579fd4b6c3996dee52ef8.zip |
fixes prepareCandidates method
-rw-r--r-- | src/ZYZPhoneticEditor.cc | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc index fa8ecb6..0baa17c 100644 --- a/src/ZYZPhoneticEditor.cc +++ b/src/ZYZPhoneticEditor.cc @@ -564,8 +564,10 @@ PhoneticEditor::selectCandidate (guint index) if (STATE_CANDIDATE_SHOWN == m_input_state) { int offset = m_phonetic_section->selectCandidate (index); +#if 0 if (0 == offset) return FALSE; +#endif m_cursor += offset; m_input_state = STATE_INPUT; @@ -1038,11 +1040,26 @@ PhoneticEditor::prepareCandidates (void) size_t index = 0; size_t start_pos = 0, end_pos = 0; - probe_section_start (enhanced_text, m_cursor, - cursor, index, start_pos); + /* hack here: we use "m_cursor - 1" to determine the section type + for candidates before cursor. */ + if (m_config.candidatesAfterCursor ()) + probe_section_start (enhanced_text, m_cursor, + cursor, index, start_pos); + else + probe_section_start (enhanced_text, m_cursor - 1, + cursor, index, start_pos); + + gboolean show_candidates = FALSE; + if (m_config.candidatesAfterCursor ()) { + show_candidates = m_cursor >= 0 && + m_cursor < get_enhanced_text_length (enhanced_text); + } else { + show_candidates = m_cursor > 0 && + m_cursor <= get_enhanced_text_length (enhanced_text); + } /* deal with candidates */ - if (m_cursor < get_enhanced_text_length (enhanced_text)) { + if (show_candidates) { section_t type = probe_section_quick (enhanced_text, start_pos); if (PHONETIC_SECTION == type) { @@ -1067,7 +1084,11 @@ PhoneticEditor::prepareCandidates (void) return TRUE; } else { m_input_state = STATE_CANDIDATE_SHOWN; - m_phonetic_section->initCandidates (instance, cursor); + if (m_config.candidatesAfterCursor ()) + m_phonetic_section->initCandidates (instance, cursor); + else + /* hack here: restore cursor. */ + m_phonetic_section->initCandidates (instance, cursor + 1); update (); return TRUE; |