add update pinyin
authorPeng Wu <alexepico@gmail.com>
Wed, 21 Sep 2011 06:52:09 +0000 (14:52 +0800)
committerPeng Wu <alexepico@gmail.com>
Thu, 22 Dec 2011 04:23:12 +0000 (12:23 +0800)
src/PYPDoublePinyinEditor.cc
src/PYPDoublePinyinEditor.h
src/PYPFullPinyinEditor.cc

index 5eb2067..501ec30 100644 (file)
@@ -38,3 +38,19 @@ LibPinyinDoublePinyinEditor::processKeyEvent (guint keyval, guint keycode,
 
     return LibPinyinPinyinEditor::processKeyEvent (keyval, keycode, modifiers);
 }
+
+void
+LibPinyinDoublePinyinEditor::updatePinyin (void)
+{
+    if (G_UNLIKELY (m_text.empty ())) {
+        m_pinyins.clear ();
+        m_pinyin_len = 0;
+        /* TODO: check whether to replace "" with NULL. */
+        pinyin_parse_more_double_pinyins (m_instance, "");
+        return;
+    }
+
+    m_pinyin_len =
+        pinyin_parse_more_double_pinyins (m_instance, m_text.c_str ());
+    pinyin_guess_sentence (m_instance);
+}
index f0cb548..d756fbd 100644 (file)
@@ -32,18 +32,6 @@ public:
 
     gboolean insert (gint ch);
 
-    gboolean removeCharBefore (void);
-    gboolean removeCharAfter (void);
-    gboolean removeWordBefore (void);
-    gboolean removeWordAfter (void);
-
-    gboolean moveCursorLeft (void);
-    gboolean moveCursorRight (void);
-    gboolean moveCursorLeftByWord (void);
-    gboolean moveCursorRightByWord (void);
-    gboolean moveCursorToBegin (void);
-    gboolean moveCursorToEnd (void);
-
     /* override virtual functions */
     gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers);
     void reset (void);
index 9c1644e..05de60d 100644 (file)
@@ -69,6 +69,8 @@ LibPinyinFullPinyinEditor::updatePinyin (void)
     if (G_UNLIKELY (m_text.empty ())) {
         m_pinyins.clear ();
         m_pinyin_len = 0;
+        /* TODO: check whether to replace "" with NULL. */
+        pinyin_parse_more_full_pinyins (m_instance, "");
         return;
     }
 
@@ -88,11 +90,11 @@ LibPinyinFullPinyinEditor::updatePinyin (void)
         PinyinSegment py = *iter;
         pinyin_parse_full_pinyin (m_instance, py.pinyin->text, &key);
         pos.set_pos (py.begin); pos.set_length (py.len);
-        g_array_append_val(m_instance->m_pinyin_keys, key);
-        g_array_append_val(m_instance->m_pinyin_poses, pos);
+        g_array_append_val (m_instance->m_pinyin_keys, key);
+        g_array_append_val (m_instance->m_pinyin_poses, pos);
     }
 
-    pinyin_guess_sentence(m_instance);
+    pinyin_guess_sentence (m_instance);
 }
 
 void