summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2022-03-29 11:06:27 +0800
committerPeng Wu <alexepico@gmail.com>2022-03-29 11:06:27 +0800
commit4491df69487217c7d7706cb50cc08ef796e4e549 (patch)
treeb2a16f2e2f295367b6ea11b3bcadcc3ec77829b5 /src
parent65b0919d45ea36b51f89881341f05fadaf60a846 (diff)
Fix commit issue in class EnglishCandidates
Diffstat (limited to 'src')
-rw-r--r--src/PYPEnglishCandidates.cc2
-rw-r--r--src/PYPEnhancedCandidates.h4
-rw-r--r--src/PYPPhoneticEditor.cc15
-rw-r--r--src/PYPPhoneticEditor.h1
4 files changed, 20 insertions, 2 deletions
diff --git a/src/PYPEnglishCandidates.cc b/src/PYPEnglishCandidates.cc
index 8f1a3b2..45a6060 100644
--- a/src/PYPEnglishCandidates.cc
+++ b/src/PYPEnglishCandidates.cc
@@ -83,7 +83,7 @@ EnglishCandidates::selectCandidate (EnhancedCandidate & enhanced)
m_english_database->train (enhanced.m_display_string.c_str (), m_train_factor);
- return SELECT_CANDIDATE_COMMIT;
+ return SELECT_CANDIDATE_DIRECT_COMMIT;
}
gboolean
diff --git a/src/PYPEnhancedCandidates.h b/src/PYPEnhancedCandidates.h
index beb2b70..d4257fb 100644
--- a/src/PYPEnhancedCandidates.h
+++ b/src/PYPEnhancedCandidates.h
@@ -49,7 +49,9 @@ enum SelectCandidateAction {
/* modify the current candidate in place */
SELECT_CANDIDATE_MODIFY_IN_PLACE = 0x2,
/* need to call update method in class Editor. */
- SELECT_CANDIDATE_UPDATE = 0x4
+ SELECT_CANDIDATE_UPDATE = 0x4,
+ /* commit the text without append the rest input after the pinyin */
+ SELECT_CANDIDATE_DIRECT_COMMIT = 0x8
};
struct EnhancedCandidate {
diff --git a/src/PYPPhoneticEditor.cc b/src/PYPPhoneticEditor.cc
index a7f74d8..76938e3 100644
--- a/src/PYPPhoneticEditor.cc
+++ b/src/PYPPhoneticEditor.cc
@@ -507,6 +507,9 @@ PhoneticEditor::selectCandidate (guint index)
if (action & SELECT_CANDIDATE_UPDATE)
update ();
+ if (action & SELECT_CANDIDATE_DIRECT_COMMIT)
+ directCommit (candidate.m_display_string.c_str ());
+
return TRUE;
}
@@ -523,6 +526,18 @@ PhoneticEditor::selectCandidateInPage (guint i)
return selectCandidate (i);
}
+void
+PhoneticEditor::directCommit (const gchar *str)
+{
+ if (G_UNLIKELY (m_text.empty ()))
+ return;
+
+ Text text (str);
+ commitText (text);
+
+ reset();
+}
+
gboolean
PhoneticEditor::removeCharBefore (void)
{
diff --git a/src/PYPPhoneticEditor.h b/src/PYPPhoneticEditor.h
index 86be2b5..2a16d87 100644
--- a/src/PYPPhoneticEditor.h
+++ b/src/PYPPhoneticEditor.h
@@ -84,6 +84,7 @@ protected:
virtual gboolean removeCandidateInternal (EnhancedCandidate & candidate);
gboolean selectCandidate (guint i);
gboolean selectCandidateInPage (guint i);
+ void directCommit (const gchar *str);
void commit () { selectCandidate (0); }