summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-07-04 14:35:42 +0800
committerPeng Wu <alexepico@gmail.com>2016-07-04 14:35:42 +0800
commited7159efd0c86b2ed22c0ddceecda90b49d764a8 (patch)
tree691bec3a5aa96a9bfbd212bb9bbd67313ecb3a43 /src
parentfbbb593328a437bb5f7e35f43c3a5838852566ae (diff)
downloadibus-libpinyin-ed7159efd0c86b2ed22c0ddceecda90b49d764a8.tar.gz
ibus-libpinyin-ed7159efd0c86b2ed22c0ddceecda90b49d764a8.tar.xz
ibus-libpinyin-ed7159efd0c86b2ed22c0ddceecda90b49d764a8.zip
port code to use libpinyin 1.5.91
Diffstat (limited to 'src')
-rw-r--r--src/PYLibPinyin.cc47
-rw-r--r--src/PYPPhoneticEditor.cc4
2 files changed, 8 insertions, 43 deletions
diff --git a/src/PYLibPinyin.cc b/src/PYLibPinyin.cc
index 9905440..179a454 100644
--- a/src/PYLibPinyin.cc
+++ b/src/PYLibPinyin.cc
@@ -311,47 +311,12 @@ LibPinyinBackEnd::clearPinyinUserData (const char * target)
gboolean
LibPinyinBackEnd::rememberUserInput (pinyin_instance_t * instance)
{
- /* pre-check the incomplete pinyin keys. */
- guint len = 0;
- g_assert (pinyin_get_n_pinyin (instance, &len));
-
- if (0 == len || len >= MAX_PHRASE_LENGTH)
- return FALSE;
-
- size_t i = 0;
- for ( ; i < len; ++i) {
- PinyinKey *key = NULL;
- g_assert (pinyin_get_pinyin_key (instance, i, &key));
- if (pinyin_get_pinyin_is_incomplete (instance, key))
- return FALSE;
- }
-
- /* prepare pinyin string. */
- GPtrArray *array = g_ptr_array_new ();
- for (i = 0; i < len; ++i) {
- PinyinKey *key = NULL;
- g_assert (pinyin_get_pinyin_key (instance, i, &key));
- gchar * pinyin = NULL;
- g_assert (pinyin_get_pinyin_string (instance, key, &pinyin));
- g_ptr_array_add (array, pinyin);
- }
- g_ptr_array_add (array, NULL);
-
- gchar **strings = (gchar **) g_ptr_array_free (array, FALSE);
- gchar *pinyins = g_strjoinv ("'", strings);
- g_strfreev (strings);
-
- /* remember user input. */
- import_iterator_t * iter = NULL;
- pinyin_context_t * context = pinyin_get_context (instance);
- iter = pinyin_begin_add_phrases (context, USER_DICTIONARY);
- char * phrase = NULL;
- g_assert (pinyin_get_sentence (instance, &phrase));
- g_assert (pinyin_iterator_add_phrase (iter, phrase, pinyins, -1));
- pinyin_end_add_phrases (iter);
- g_free (phrase);
- g_free (pinyins);
-
+ /* pre-check the incomplete pinyin keys, prepare pinyin string,
+ remember user input. */
+ gchar * sentence = NULL;
+ pinyin_get_sentence (instance, &sentence);
+ pinyin_remember_user_input (instance, sentence, -1);
+ g_free (sentence);
/* save later,
will mark modified from pinyin/bopomofo editor. */
return TRUE;
diff --git a/src/PYPPhoneticEditor.cc b/src/PYPPhoneticEditor.cc
index d6ac3d9..0c064aa 100644
--- a/src/PYPPhoneticEditor.cc
+++ b/src/PYPPhoneticEditor.cc
@@ -497,7 +497,7 @@ PhoneticEditor::getCursorLeftByWord (void)
size_t cursor = 0;
- pinyin_get_left_character_offset(m_instance, offset, &cursor);
+ pinyin_get_left_pinyin_offset(m_instance, offset, &cursor);
return cursor;
}
@@ -511,7 +511,7 @@ PhoneticEditor::getCursorRightByWord (void)
size_t cursor = 0;
- pinyin_get_right_character_offset(m_instance, offset, &cursor);
+ pinyin_get_right_pinyin_offset(m_instance, offset, &cursor);
return cursor;
}