summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2014-08-19 14:29:57 +0800
committerPeng Wu <alexepico@gmail.com>2014-08-19 14:29:57 +0800
commit471752e4519fa4f5785cfb454f1c24f747717d89 (patch)
tree57997f55cca665431683d6a85a967a480e4700fd /src
parentf53b1287772ff4d7589f4c4b3847c7a74ee293ef (diff)
downloadibus-libpinyin-471752e4519fa4f5785cfb454f1c24f747717d89.tar.gz
ibus-libpinyin-471752e4519fa4f5785cfb454f1c24f747717d89.tar.xz
ibus-libpinyin-471752e4519fa4f5785cfb454f1c24f747717d89.zip
use pinyin_get_pinyin_key_rest_offset function
Diffstat (limited to 'src')
-rw-r--r--src/PYPPhoneticEditor.cc17
1 files changed, 2 insertions, 15 deletions
diff --git a/src/PYPPhoneticEditor.cc b/src/PYPPhoneticEditor.cc
index 0be3a7b..a5622c7 100644
--- a/src/PYPPhoneticEditor.cc
+++ b/src/PYPPhoneticEditor.cc
@@ -313,24 +313,11 @@ guint
PhoneticEditor::getPinyinCursor ()
{
guint len = 0;
- pinyin_get_n_pinyin (m_instance, &len);
/* Translate cursor position to pinyin position. */
- guint pinyin_cursor = len;
-
- guint16 prev_end = 0, cur_end;
- for (size_t i = 0; i < len; ++i) {
- PinyinKeyPos *pos = NULL;
- pinyin_get_pinyin_key_rest (m_instance, i, &pos);
- pinyin_get_pinyin_key_rest_positions (m_instance, pos, NULL, &cur_end);
-
- if (prev_end <= m_cursor && m_cursor < cur_end)
- pinyin_cursor = i;
-
- prev_end = cur_end;
- }
+ guint16 pinyin_cursor = 0;
+ pinyin_get_pinyin_key_rest_offset (m_instance, m_cursor, &pinyin_cursor);
- g_assert (pinyin_cursor >= 0);
return pinyin_cursor;
}