diff options
Diffstat (limited to 'src/PYPFullPinyinEditor.cc')
-rw-r--r-- | src/PYPFullPinyinEditor.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/PYPFullPinyinEditor.cc b/src/PYPFullPinyinEditor.cc index 70de09f..b0ad3d7 100644 --- a/src/PYPFullPinyinEditor.cc +++ b/src/PYPFullPinyinEditor.cc @@ -116,3 +116,21 @@ FullPinyinEditor::update (void) updatePreeditText (); updateAuxiliaryText (); } + +guint +FullPinyinEditor::getLookupCursor (void) +{ + guint lookup_cursor = getPinyinCursor (); + + /* as pinyin_get_pinyin_offset can't handle the last "'" characters, + strip the string to work around it here. */ + String stripped = m_text; + size_t pos = stripped.find_last_not_of ("'") + 1; + if (pos < stripped.length ()) + stripped.erase (pos); + + /* show candidates when pinyin cursor is at end. */ + if (lookup_cursor == stripped.length ()) + lookup_cursor = 0; + return lookup_cursor; +} |