diff options
author | Peng Wu <alexepico@gmail.com> | 2018-06-06 16:11:45 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2018-06-06 16:11:45 +0800 |
commit | de688e73654da6a7ace797f35e34275daa4980d3 (patch) | |
tree | 5391763239a3b599b696bfddeea60663dfe2be57 /src/PYPPhoneticEditor.cc | |
parent | 927d3e23a6b8ee30b26b9fe8203c5fc4e56baf52 (diff) | |
download | ibus-libpinyin-de688e73654da6a7ace797f35e34275daa4980d3.tar.gz ibus-libpinyin-de688e73654da6a7ace797f35e34275daa4980d3.tar.xz ibus-libpinyin-de688e73654da6a7ace797f35e34275daa4980d3.zip |
re-factor selectCandidate method
Diffstat (limited to 'src/PYPPhoneticEditor.cc')
-rw-r--r-- | src/PYPPhoneticEditor.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/PYPPhoneticEditor.cc b/src/PYPPhoneticEditor.cc index 324eabd..bbf40f7 100644 --- a/src/PYPPhoneticEditor.cc +++ b/src/PYPPhoneticEditor.cc @@ -350,6 +350,7 @@ PhoneticEditor::selectCandidateInternal (EnhancedCandidate & candidate) } } +#if 0 gboolean PhoneticEditor::selectCandidate (guint i) { @@ -396,6 +397,40 @@ PhoneticEditor::selectCandidate (guint i) update (); return TRUE; } +#endif + +gboolean +PhoneticEditor::selectCandidate (guint i) +{ + if (G_UNLIKELY (i >= m_candidates.size ())) + return FALSE; + + EnhancedCandidate & candidate = m_candidates[i]; + SelectCandidateAction action = selectCandidateInternal (candidate); + + switch (action) { + case SELECT_CANDIDATE_ALREADY_HANDLED: + return TRUE; + + case SELECT_CANDIDATE_COMMIT: + case SELECT_CANDIDATE_MODIFY_IN_PLACE_AND_COMMIT: { + Text text (candidate.m_display_string.c_str ()); + commitText (text); + /* call pinyin_train and rememberUserInput here */ + assert (FALSE); + return TRUE; + } + + case SELECT_CANDIDATE_UPDATE_ALL: + update (); + return TRUE; + + default: + assert (FALSE); + } + + return FALSE; +} gboolean PhoneticEditor::selectCandidateInPage (guint i) |