From 33fbca959cd63cf5de0c36695d9ec03dd8d7095a Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 21 Mar 2013 16:16:59 +0800 Subject: write get pinyin key and rest methods --- src/pinyin.cpp | 30 ++++++++++++++++++++++++++++++ src/pinyin.h | 21 +++++++++++++++++++++ 2 files changed, 51 insertions(+) (limited to 'src') diff --git a/src/pinyin.cpp b/src/pinyin.cpp index 21ea69c..34e6bde 100644 --- a/src/pinyin.cpp +++ b/src/pinyin.cpp @@ -1954,6 +1954,36 @@ bool pinyin_get_n_pinyin(pinyin_instance_t * instance, return true; } +bool pinyin_get_pinyin_key(pinyin_instance_t * instance, + guint index, + ChewingKey ** key) { + ChewingKeyVector & pinyin_keys = instance->m_pinyin_keys; + + *key = NULL; + + if (index >= pinyin_keys->len) + return false; + + *key = &g_array_index(pinyin_keys, ChewingKey, index); + + return true; +} + +bool pinyin_get_pinyin_key_rest(pinyin_instance_t * instance, + guint index, + ChewingKeyRest ** key_rest) { + ChewingKeyRestVector & pinyin_key_rests = instance->m_pinyin_key_rests; + + *key_rest = NULL; + + if (index >= pinyin_key_rests->len) + return false; + + *key_rest = &g_array_index(pinyin_key_rests, ChewingKeyRest, index); + + return true; +} + /** * Note: prefix is the text before the pre-edit string. */ diff --git a/src/pinyin.h b/src/pinyin.h index ce49517..a038327 100644 --- a/src/pinyin.h +++ b/src/pinyin.h @@ -581,6 +581,27 @@ bool pinyin_get_candidate_string(pinyin_instance_t * instance, bool pinyin_get_n_pinyin(pinyin_instance_t * instance, guint * num); +bool pinyin_get_pinyin_key(pinyin_instance_t * instance, + guint index, + ChewingKey ** key); + +bool pinyin_get_pinyin_key_rest(pinyin_instance_t * instance, + guint index, + ChewingKeyRest ** key_rest); + +bool pinyin_get_key_rest_positions(pinyin_instance_t * instance, + ChewingKeyRest * key_rest, + guint16 * begin, guint16 * end); + +bool pinyin_get_key_rest_length(pinyin_instance_t * instance, + ChewingKeyRest * key_rest, + guint16 * len); + +bool pinyin_get_raw_pinyin_input(pinyin_instance_t * instance, + const gchar ** utf8_str); + + + /* hack here. */ typedef ChewingKey PinyinKey; typedef ChewingKeyRest PinyinKeyPos; -- cgit