diff options
author | Peng Wu <alexepico@gmail.com> | 2018-06-06 16:57:42 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2018-06-06 16:57:42 +0800 |
commit | e9cb1572f84785cada0e5434d1b992ba1298b1a4 (patch) | |
tree | a15b27c15cb590a1d3ba92f1aec82e1136099376 /src/PYPBopomofoEditor.cc | |
parent | de688e73654da6a7ace797f35e34275daa4980d3 (diff) | |
download | ibus-libpinyin-e9cb1572f84785cada0e5434d1b992ba1298b1a4.tar.gz ibus-libpinyin-e9cb1572f84785cada0e5434d1b992ba1298b1a4.tar.xz ibus-libpinyin-e9cb1572f84785cada0e5434d1b992ba1298b1a4.zip |
re-factor commit method
Diffstat (limited to 'src/PYPBopomofoEditor.cc')
-rw-r--r-- | src/PYPBopomofoEditor.cc | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/PYPBopomofoEditor.cc b/src/PYPBopomofoEditor.cc index 599d195..688fb5f 100644 --- a/src/PYPBopomofoEditor.cc +++ b/src/PYPBopomofoEditor.cc @@ -302,7 +302,7 @@ BopomofoEditor::updatePinyin (void) } void -BopomofoEditor::commit (gint index) +BopomofoEditor::commit (const gchar *str) { if (G_UNLIKELY (m_text.empty ())) return; @@ -310,16 +310,7 @@ BopomofoEditor::commit (gint index) m_buffer.clear (); /* sentence candidate */ - char *tmp = NULL; - pinyin_get_sentence (m_instance, index, &tmp); - if (tmp) { - if (m_props.modeSimp ()) { - m_buffer << tmp; - } else { - SimpTradConverter::simpToTrad (tmp, m_buffer); - } - g_free (tmp); - } + m_buffer << str; /* text after pinyin */ const gchar *p = m_text.c_str() + m_pinyin_len; @@ -339,11 +330,13 @@ BopomofoEditor::commit (gint index) ++p; } - pinyin_train(m_instance, index); if (m_config.rememberEveryInput ()) - LibPinyinBackEnd::instance ().rememberUserInput (m_instance, index); + LibPinyinBackEnd::instance ().rememberUserInput (m_instance, str); LibPinyinBackEnd::instance ().modified(); - PhoneticEditor::commit ((const gchar *)m_buffer); + + Text text (m_buffer.c_str ()); + commitText (text); + reset(); } |