fixes chewing editor
authorPeng Wu <alexepico@gmail.com>
Sat, 8 Oct 2011 03:40:11 +0000 (11:40 +0800)
committerPeng Wu <alexepico@gmail.com>
Thu, 22 Dec 2011 04:23:14 +0000 (12:23 +0800)
src/PYEngine.cc
src/PYPBopomofoEditor.cc

index 3a34afc..27cc312 100644 (file)
@@ -171,7 +171,7 @@ ibus_pinyin_engine_constructor (GType                  type,
             engine->engine = new LibPinyinPinyinEngine (IBUS_ENGINE (engine));
         }
         if (std::strcmp (name, "libbopomofo") == 0 ||
-            std::strcmp (name, "libbopomofo") == 0 ) {
+            std::strcmp (name, "libbopomofo-debug") == 0 ) {
             engine->engine = new LibPinyinBopomofoEngine (IBUS_ENGINE (engine));
         }
     } else {
index f13fcc9..1a330cc 100644 (file)
@@ -351,7 +351,8 @@ LibPinyinBopomofoEditor::updateAuxiliaryText (void)
 
         if (G_UNLIKELY (cursor == m_cursor)) { /* at word boundary. */
             m_buffer << '|' << key->get_key_zhuyin_string ();
-        } else { /* in word */
+        } else if (G_LIKELY ( cursor < m_cursor &&
+                              m_cursor < pos->get_end_pos() )) { /* in word */
             /* raw text */
             String raw = m_text.substr (cursor, pos->get_length ());
             guint offset = m_cursor - cursor;
@@ -366,9 +367,14 @@ LibPinyinBopomofoEditor::updateAuxiliaryText (void)
             for ( iter = after.begin (); iter != after.end (); ++iter) {
                 m_buffer << bopomofo_char[keyvalToBopomofo (*iter)];
             }
+        } else { /* other words */
+            m_buffer << ' ' << key->get_key_zhuyin_string ();
         }
     }
 
+    if (m_cursor == m_pinyin_len)
+        m_buffer << '|';
+
     /* append rest text */
     const gchar * p = m_text.c_str() + m_pinyin_len;
     m_buffer << p;