diff options
author | Peng Wu <alexepico@gmail.com> | 2020-07-21 13:02:53 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2020-07-21 13:02:53 +0800 |
commit | ac395bd59da86505b1ee00f3edd64f03f654aa33 (patch) | |
tree | 6291103047c4a3deded7cf43739d2983d057c634 | |
parent | f3faeeff3fbe3bf9e30ed4461c2c8d0466966e56 (diff) | |
download | ibus-libpinyin-ac395bd59da86505b1ee00f3edd64f03f654aa33.tar.gz ibus-libpinyin-ac395bd59da86505b1ee00f3edd64f03f654aa33.tar.xz ibus-libpinyin-ac395bd59da86505b1ee00f3edd64f03f654aa33.zip |
Fixes Bopomofo Editor
-rw-r--r-- | src/PYPBopomofoEditor.cc | 29 | ||||
-rw-r--r-- | src/PYPPhoneticEditor.cc | 6 |
2 files changed, 31 insertions, 4 deletions
diff --git a/src/PYPBopomofoEditor.cc b/src/PYPBopomofoEditor.cc index cc67a04..4992a40 100644 --- a/src/PYPBopomofoEditor.cc +++ b/src/PYPBopomofoEditor.cc @@ -309,11 +309,24 @@ BopomofoEditor::commit (const gchar *str) if (G_UNLIKELY (m_text.empty ())) return; + guint num = 0; + pinyin_get_n_candidate (m_instance, &num); + m_buffer.clear (); /* sentence candidate */ m_buffer << str; + /* un-parsed pinyin text */ + if (G_UNLIKELY (0 == num)) { + m_buffer << m_text; + Text text (m_buffer.c_str ()); + commitText (text); + + reset(); + return; + } + /* text after pinyin */ const gchar *p = m_text.c_str() + m_pinyin_len; while (*p != '\0') { @@ -344,17 +357,25 @@ BopomofoEditor::updatePreeditText () if (DISPLAY_STYLE_COMPACT == m_config.displayStyle ()) return; - guint num = 0; - pinyin_get_n_candidate (m_instance, &num); - /* preedit text = guessed sentence + un-parsed pinyin text */ - if (G_UNLIKELY (m_text.empty () || 0 == num)) { + if (G_UNLIKELY (m_text.empty ())) { hidePreeditText (); return; } + guint num = 0; + pinyin_get_n_candidate (m_instance, &num); + m_buffer.clear (); + /* un-parsed pinyin text */ + if (G_UNLIKELY (0 == num)) { + m_buffer << m_text; + StaticText preedit_text (m_buffer); + Editor::updatePreeditText (preedit_text, m_buffer.length (), TRUE); + return; + } + /* probe nbest match candidate */ lookup_candidate_type_t type; lookup_candidate_t * candidate = NULL; diff --git a/src/PYPPhoneticEditor.cc b/src/PYPPhoneticEditor.cc index 7b37e6f..4eef8ed 100644 --- a/src/PYPPhoneticEditor.cc +++ b/src/PYPPhoneticEditor.cc @@ -463,6 +463,12 @@ PhoneticEditor::selectCandidate (guint i) gboolean PhoneticEditor::selectCandidate (guint index) { + /* un-parsed text */ + if (G_UNLIKELY (0 == index && 0 == m_candidates.size ())) { + commit (""); + return TRUE; + } + if (G_UNLIKELY (index >= m_candidates.size ())) return FALSE; |