From c4f57271683ec7eb98b43ee4aae94cff1b341483 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 30 Jun 2016 14:30:46 +0800 Subject: begin to add pinyin_remember_user_input function --- src/libpinyin.ver | 1 + src/pinyin.cpp | 2 +- src/pinyin.h | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/libpinyin.ver b/src/libpinyin.ver index b53033c..ea2098a 100644 --- a/src/libpinyin.ver +++ b/src/libpinyin.ver @@ -16,6 +16,7 @@ LIBPINYIN { pinyin_iterator_has_next_phrase; pinyin_iterator_get_next_phrase; pinyin_end_get_phrases; + pinyin_remember_user_input; pinyin_fini; pinyin_mask_out; pinyin_set_options; diff --git a/src/pinyin.cpp b/src/pinyin.cpp index 6a2d189..d69e093 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -483,6 +483,7 @@ static bool _add_phrase(pinyin_context_t * context, bool result = false; + /* check whether the phrase exists in phrase table */ phrase_token_t token = null_token; GArray * tokenarray = g_array_new(FALSE, FALSE, sizeof(phrase_token_t)); @@ -577,7 +578,6 @@ bool pinyin_iterator_add_phrase(import_iterator_t * iter, if (NULL == phrase || NULL == pinyin) return result; - /* check whether the phrase exists in phrase table */ glong phrase_length = 0; ucs4_t * ucs4_phrase = g_utf8_to_ucs4(phrase, -1, NULL, &phrase_length, NULL); diff --git a/src/pinyin.h b/src/pinyin.h index 610070e..9599aab 100644 --- a/src/pinyin.h +++ b/src/pinyin.h @@ -994,7 +994,22 @@ bool pinyin_get_chewing_auxiliary_text(pinyin_instance_t * instance, size_t cursor, gchar ** aux_text); -/* hack here. */ +/** + * pinyin_remember_user_input: + * @instance: the pinyin instance. + * @phrase: the utf8 phrase. + * @count: the count of the phrase, -1 to use the default value. + * @returns: whether the phrase is remembered. + * + * Remember the current phrase and pinyin pair. + * + */ +bool pinyin_remember_user_input(pinyin_instance_t * instance, + const char * phrase, + gint count); + + +/* for compatibility. */ typedef ChewingKey PinyinKey; typedef ChewingKeyRest PinyinKeyPos; -- cgit