summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-11-07 14:40:06 +0800
committerPeng Wu <alexepico@gmail.com>2011-12-22 12:23:14 +0800
commit4b12c07f98d9e0cb437034ad5215b9001e98321e (patch)
tree133116bcc6b79e519912b811c75e8529f4e423f0
parentd51411dd4f9e728c68ccdf9949198fa6f16b753f (diff)
downloadibus-libpinyin-4b12c07f98d9e0cb437034ad5215b9001e98321e.tar.gz
fixes select candidate
-rw-r--r--src/PYPPhoneticEditor.cc16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/PYPPhoneticEditor.cc b/src/PYPPhoneticEditor.cc
index a249b54..c5c8041 100644
--- a/src/PYPPhoneticEditor.cc
+++ b/src/PYPPhoneticEditor.cc
@@ -343,16 +343,30 @@ LibPinyinPhoneticEditor::selectCandidate (guint i)
if (G_UNLIKELY (i >= m_candidates->len))
return FALSE;
+ PinyinKeyVector & pinyins = m_instance->m_pinyin_keys;
guint pinyin_cursor = getPinyinCursor ();
+ /* show candidates when pinyin cursor is at end. */
+ if (pinyin_cursor == pinyins->len && m_pinyin_len == m_text.length())
+ pinyin_cursor = 0;
/* NOTE: deal with normal candidates selection here by libpinyin. */
phrase_token_t *token = &g_array_index (m_candidates, phrase_token_t, i);
+ if (null_token == *token) {
+ commit ();
+ return TRUE;
+ }
+
guint8 len = pinyin_choose_candidate (m_instance, pinyin_cursor, *token);
pinyin_guess_sentence (m_instance);
+ PinyinKeyPosVector & pinyin_poses = m_instance->m_pinyin_poses;
pinyin_cursor += len;
+ if (pinyin_cursor == pinyin_poses->len) {
+ commit();
+ return TRUE;
+ }
PinyinKeyPos *pos = &g_array_index
- (m_instance->m_pinyin_poses, PinyinKeyPos, pinyin_cursor);
+ (pinyin_poses, PinyinKeyPos, pinyin_cursor);
m_cursor = pos->get_pos();
return TRUE;