summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2018-06-06 16:11:45 +0800
committerPeng Wu <alexepico@gmail.com>2018-06-06 16:11:45 +0800
commitde688e73654da6a7ace797f35e34275daa4980d3 (patch)
tree5391763239a3b599b696bfddeea60663dfe2be57 /src
parent927d3e23a6b8ee30b26b9fe8203c5fc4e56baf52 (diff)
downloadibus-libpinyin-de688e73654da6a7ace797f35e34275daa4980d3.tar.gz
ibus-libpinyin-de688e73654da6a7ace797f35e34275daa4980d3.tar.xz
ibus-libpinyin-de688e73654da6a7ace797f35e34275daa4980d3.zip
re-factor selectCandidate method
Diffstat (limited to 'src')
-rw-r--r--src/PYPBopomofoEditor.cc6
-rw-r--r--src/PYPPhoneticEditor.cc35
2 files changed, 39 insertions, 2 deletions
diff --git a/src/PYPBopomofoEditor.cc b/src/PYPBopomofoEditor.cc
index dd19fa7..599d195 100644
--- a/src/PYPBopomofoEditor.cc
+++ b/src/PYPBopomofoEditor.cc
@@ -219,8 +219,10 @@ BopomofoEditor::processKeyEvent (guint keyval, guint keycode,
if (m_config.enterKey ())
commit ();
- else
- PhoneticEditor::commit (m_text.c_str ());
+ else {
+ Text text (m_text.c_str ());
+ commitText (text);
+ }
reset ();
return TRUE;
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)