summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-08-08 13:08:56 +0800
committerPeng Wu <alexepico@gmail.com>2016-08-08 13:08:56 +0800
commitefaff649a8621801e77613035fca50c371ba334e (patch)
treee1feae6d1ebf869adbc233d289cb6eff6472c7b2
parenta8f282b9e3843022cc80f8aa36d6f51e0a4f8860 (diff)
downloadibus-libpinyin-efaff649a8621801e77613035fca50c371ba334e.tar.gz
ibus-libpinyin-efaff649a8621801e77613035fca50c371ba334e.tar.xz
ibus-libpinyin-efaff649a8621801e77613035fca50c371ba334e.zip
fixes getLookupCursor method
-rw-r--r--src/PYPFullPinyinEditor.cc18
-rw-r--r--src/PYPFullPinyinEditor.h2
-rw-r--r--src/PYPPhoneticEditor.cc9
3 files changed, 21 insertions, 8 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;
+}
diff --git a/src/PYPFullPinyinEditor.h b/src/PYPFullPinyinEditor.h
index cffbdd9..84a160f 100644
--- a/src/PYPFullPinyinEditor.h
+++ b/src/PYPFullPinyinEditor.h
@@ -44,6 +44,8 @@ protected:
virtual void updatePinyin (void);
+ virtual guint getLookupCursor (void);
+
};
};
diff --git a/src/PYPPhoneticEditor.cc b/src/PYPPhoneticEditor.cc
index 517bac4..0ef11d7 100644
--- a/src/PYPPhoneticEditor.cc
+++ b/src/PYPPhoneticEditor.cc
@@ -365,15 +365,8 @@ PhoneticEditor::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 ())
+ if (lookup_cursor == m_text.length ())
lookup_cursor = 0;
return lookup_cursor;
}