fixes full editor
authorPeng Wu <alexepico@gmail.com>
Sat, 8 Oct 2011 02:37:40 +0000 (10:37 +0800)
committerPeng Wu <alexepico@gmail.com>
Thu, 22 Dec 2011 04:23:13 +0000 (12:23 +0800)
src/PYPFullPinyinEditor.cc
src/PYPPhoneticEditor.cc
src/PYPPinyinEngine.cc

index f07204b..0b7d603 100644 (file)
@@ -122,12 +122,15 @@ LibPinyinFullPinyinEditor::updateAuxiliaryText ()
 
         if (G_UNLIKELY (cursor == m_cursor)) { /* at word boundary. */
             m_buffer << '|' << key->get_key_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;
             m_buffer << ' ' << raw.substr (0, offset)
                      << '|' << raw.substr (offset);
+        } else { /* other words */
+            m_buffer << ' ' << key->get_key_string ();
         }
     }
 
index 6fde250..14773a7 100644 (file)
@@ -32,6 +32,7 @@ LibPinyinPhoneticEditor::LibPinyinPhoneticEditor (PinyinProperties &props,
     m_pinyin_len (0),
     m_lookup_table (m_config.pageSize ())
 {
+    m_candidates = g_array_new(FALSE, TRUE, sizeof(phrase_token_t));
 }
 
 gboolean
@@ -281,6 +282,8 @@ LibPinyinPhoneticEditor::reset (void)
 void
 LibPinyinPhoneticEditor::update (void)
 {
+    guint pinyin_cursor = getPinyinCursor ();
+    pinyin_get_candidates (m_instance, pinyin_cursor, m_candidates);
     updateLookupTable ();
     updatePreeditText ();
     updateAuxiliaryText ();
index c163cfc..4aae9a9 100644 (file)
@@ -149,8 +149,8 @@ LibPinyinPinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modif
                     break;
 #endif
                 }
-            } else { /* Unknown */
-                g_warn_if_reached ();
+            } else {
+                /* TODO: Unknown */
             }
         }
         retval = m_editors[m_input_mode]->processKeyEvent (keyval, keycode, modifiers);