From 471752e4519fa4f5785cfb454f1c24f747717d89 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 19 Aug 2014 14:29:57 +0800 Subject: use pinyin_get_pinyin_key_rest_offset function --- src/PYPPhoneticEditor.cc | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'src/PYPPhoneticEditor.cc') 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; } -- cgit