updateAuxiliaryTextBefore (m_buffer);
if (m_selected_special_phrase.empty ()) {
- for (guint i = m_phrase_editor.cursor (); i < m_pinyin.size (); ++i) {
- if (G_LIKELY (i != m_phrase_editor.cursor ()))
- m_buffer << ' ';
- const Pinyin *p = m_pinyin[i];
- m_buffer << p->sheng
- << p->yun;
- }
-
- if (G_UNLIKELY (m_pinyin_len == m_cursor)) {
- /* aux = pinyin + non-pinyin */
- // cursor_pos = m_buffer.utf8Length ();
- m_buffer << '|' << textAfterPinyin ();
+ if (m_lookup_table.cursorPos () < m_special_phrases.size ()) {
+ guint begin = m_phrase_editor.cursorInChar ();
+ m_buffer << m_text.substr (begin, m_cursor - begin)
+ << '|' << textAfterCursor ();
}
else {
- /* aux = pinyin + ' ' + non-pinyin before cursor + non-pinyin after cursor */
- m_buffer << ' ';
- m_buffer.append (textAfterPinyin (),
- m_cursor - m_pinyin_len);
- // cursor_pos = m_buffer.utf8Length ();
- m_buffer << '|' << textAfterCursor ();
+ for (guint i = m_phrase_editor.cursor (); i < m_pinyin.size (); ++i) {
+ if (G_LIKELY (i != m_phrase_editor.cursor ()))
+ m_buffer << ' ';
+ const Pinyin *p = m_pinyin[i];
+ m_buffer << p->sheng
+ << p->yun;
+ }
+
+ if (G_UNLIKELY (m_pinyin_len == m_cursor)) {
+ /* aux = pinyin + non-pinyin */
+ // cursor_pos = m_buffer.utf8Length ();
+ m_buffer << '|' << textAfterPinyin ();
+ }
+ else {
+ /* aux = pinyin + ' ' + non-pinyin before cursor + non-pinyin after cursor */
+ m_buffer << ' ';
+ m_buffer.append (textAfterPinyin (),
+ m_cursor - m_pinyin_len);
+ // cursor_pos = m_buffer.utf8Length ();
+ m_buffer << '|' << textAfterCursor ();
+ }
}
}
else {
if (G_LIKELY (m_lookup_table.pageUp ())) {
updateLookupTableFast (m_lookup_table, TRUE);
updatePreeditText ();
+ updateAuxiliaryText ();
}
}
(fillLookupTableByPage () && m_lookup_table.pageDown ()))) {
updateLookupTableFast (m_lookup_table, TRUE);
updatePreeditText ();
+ updateAuxiliaryText ();
}
}
if (G_LIKELY (m_lookup_table.cursorUp ())) {
updateLookupTableFast (m_lookup_table, TRUE);
updatePreeditText ();
+ updateAuxiliaryText ();
}
}
if (G_LIKELY (m_lookup_table.cursorDown ())) {
updateLookupTableFast (m_lookup_table, TRUE);
updatePreeditText ();
+ updateAuxiliaryText ();
}
}
updateAuxiliaryText ();
}
-void
-PinyinEditor::updatePhraseEditor (void)
-{
- m_phrase_editor.update (m_pinyin);
-}
-
inline void
PinyinEditor::commit (const gchar *str)
{
void updateLookupTable (void);
gboolean fillLookupTableByPage (void);
- void updatePhraseEditor (void);
+ void updatePhraseEditor (void) { m_phrase_editor.update (m_pinyin); }
+
+ gboolean updateSpecialPhrases (void) {
+ if (!m_selected_special_phrase.empty ())
+ return FALSE;
+
+ guint size = m_special_phrases.size ();
+ guint begin = m_phrase_editor.cursorInChar ();
+ guint end = m_cursor;
+
+ m_special_phrases.clear ();
+ if (begin < end) {
+ SpecialTable::instance ().lookup (
+ m_text.substr (begin, m_cursor - begin),
+ m_special_phrases);
+ }
+
+ return size != m_special_phrases.size () || size != 0;
+ }
gboolean selectCandidate (guint i);
gboolean selectCandidateInPage (guint i);
guint pinyinLength (void) const { return m_pinyin_len; }
operator gboolean (void) const { return ! empty (); }
- gboolean updateSpecialPhrases (void) {
- guint oldsize = m_special_phrases.size ();
- m_special_phrases.clear ();
- guint begin = m_phrase_editor.cursorInChar ();
- guint end = m_cursor;
-
- if (begin < end &&
- m_selected_special_phrase.empty () &&
- SpecialTable::instance ().lookup (m_text.substr (begin, m_cursor - begin), m_special_phrases)) {
- return TRUE;
- }
- return oldsize > 0;
- }
-
/* virtual functions */
virtual gboolean insert (gint ch) = 0;
virtual gboolean removeCharBefore (void) = 0;