summaryrefslogtreecommitdiffstats
path: root/src/PYPBopomofoEditor.cc
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2011-09-22 15:18:37 +0800
committerPeng Wu <alexepico@gmail.com>2011-12-22 12:23:12 +0800
commitaea71c5a524cb814cb1697ed4b97a944eb899db6 (patch)
tree14c02794b5db9ba15b0de24bb7ba732c7730b9c8 /src/PYPBopomofoEditor.cc
parent3b2103d9293ce891f4b47173f60b194916046b18 (diff)
downloadibus-libpinyin-aea71c5a524cb814cb1697ed4b97a944eb899db6.tar.gz
ibus-libpinyin-aea71c5a524cb814cb1697ed4b97a944eb899db6.tar.xz
ibus-libpinyin-aea71c5a524cb814cb1697ed4b97a944eb899db6.zip
write bopomofo editor
Diffstat (limited to 'src/PYPBopomofoEditor.cc')
-rw-r--r--src/PYPBopomofoEditor.cc35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/PYPBopomofoEditor.cc b/src/PYPBopomofoEditor.cc
index 3a2a70e..023634b 100644
--- a/src/PYPBopomofoEditor.cc
+++ b/src/PYPBopomofoEditor.cc
@@ -22,6 +22,8 @@
#include "PYConfig.h"
#include "PYPinyinProperties.h"
#include "PYSimpTradConverter.h"
+#include "PYHalfFullConverter.h"
+
namespace PY {
#include "PYBopomofoKeyboard.h"
@@ -259,7 +261,38 @@ LibPinyinBopomofoEditor::keyvalToBopomofo(gint ch)
void
LibPinyinBopomofoEditor::commit ()
{
- g_assert (FALSE);
+ if (G_UNLIKELY (m_text.empty ()))
+ return;
+
+ m_buffer.clear ();
+
+ /* sentence candidate */
+ char *tmp = NULL;
+ pinyin_get_sentence(m_instance, &tmp);
+ if (m_props.modeSimp ()) {
+ m_buffer << tmp;
+ } else {
+ SimpTradConverter::simpToTrad (tmp, m_buffer);
+ }
+ g_free (tmp);
+
+ /* text after pinyin */
+ const gchar *p = m_text.c_str() + m_pinyin_len;
+ while (*p != '\0') {
+ if (keyvalToBopomofo (*p)) {
+ m_buffer << keyvalToBopomofo (*p);
+ } else {
+ if (G_UNLIKELY (m_props.modeFull ())) {
+ m_buffer.appendUnichar (HalfFullConverter::toFull (*p++));
+ } else {
+ m_buffer << p;
+ }
+ }
+ }
+
+ pinyin_train(m_instance);
+ LibPinyinPhoneticEditor::commit ((const gchar *)m_buffer);
+ reset();
}
void