diff options
author | Peng Wu <alexepico@gmail.com> | 2017-05-23 17:40:29 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2017-05-23 17:43:17 +0800 |
commit | cd999ede281325cdde1942fbd86487af4b88d3dd (patch) | |
tree | a8d3da6fa5be859ff817d48f562278cb459af5ef | |
parent | e6ff8c72bd4de2f02a7c26c9e4d614646fb12e62 (diff) | |
download | ibus-libzhuyin-cd999ede281325cdde1942fbd86487af4b88d3dd.tar.gz ibus-libzhuyin-cd999ede281325cdde1942fbd86487af4b88d3dd.tar.xz ibus-libzhuyin-cd999ede281325cdde1942fbd86487af4b88d3dd.zip |
fixes compile
-rw-r--r-- | src/ZYZConfig.cc | 2 | ||||
-rw-r--r-- | src/ZYZPhoneticEditor.cc | 57 | ||||
-rw-r--r-- | src/ZYZPhoneticSection.cc | 26 |
3 files changed, 25 insertions, 60 deletions
diff --git a/src/ZYZConfig.cc b/src/ZYZConfig.cc index 40facad..8f8ad6c 100644 --- a/src/ZYZConfig.cc +++ b/src/ZYZConfig.cc @@ -266,7 +266,7 @@ ZhuyinConfig::valueChanged (const std::string §ion, else if (CONFIG_CANDIDATES_AFTER_CURSOR == name) m_candidates_after_cursor = normalizeGVariant (value, true); else if (CONFIG_KEYBOARD_LAYOUT == name) { - gint layout = read (CONFIG_KEYBOARD_LAYOUT, 0); + gint layout = normalizeGVariant (value, 0); m_is_zhuyin = TRUE; m_zhuyin_scheme = ZHUYIN_DEFAULT; diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc index 2660202..d7d570a 100644 --- a/src/ZYZPhoneticEditor.cc +++ b/src/ZYZPhoneticEditor.cc @@ -701,20 +701,15 @@ PhoneticEditor::getCursorLeft (void) /* only when in parsed phonetic section, need adjustments. */ if (cursor < parsed_len) { - guint16 offset = 0; - zhuyin_get_zhuyin_key_rest_offset (instance, cursor, &offset); + size_t offset = 0; + zhuyin_get_zhuyin_offset (m_instance, cursor, &offset); - /* move to the begin of current syllable. */ - ChewingKeyRest * key_rest = NULL; - zhuyin_get_zhuyin_key_rest (instance, offset, &key_rest); - - guint16 begin = 0; - zhuyin_get_zhuyin_key_rest_positions - (instance, key_rest, &begin, NULL); + size_t left = 0; + zhuyin_get_left_zhuyin_offset(m_instance, offset, &left); /* align to the begin of chewing key. */ /* restore cursor variable. */ - return m_cursor - (cursor + 1 - begin); + return m_cursor - cursor + left; } } @@ -750,29 +745,13 @@ PhoneticEditor::getCursorRight (void) /* when in parsed phonetic section, need adjustments. */ if (cursor < parsed_len) { - guint16 offset = 0; - zhuyin_get_zhuyin_key_rest_offset (instance, cursor, &offset); - offset ++; - - guint len = 0; - zhuyin_get_n_zhuyin (instance, &len); - - if (offset < len) { - /* move to the begin of next syllable. */ - ChewingKeyRest * key_rest = NULL; - zhuyin_get_zhuyin_key_rest (instance, offset, &key_rest); + size_t offset = 0; + zhuyin_get_zhuyin_offset (m_instance, cursor, &offset); - guint16 begin = 0; - zhuyin_get_zhuyin_key_rest_positions - (instance, key_rest, &begin, NULL); + size_t right = 0; + zhuyin_get_right_zhuyin_offset(m_instance, offset, &right); - /* align to the begin of chewing key. */ - return m_cursor + (begin - cursor); - } else { - assert (offset == len); - /* align to the end of parsed phonetic section. */ - return m_cursor + (parsed_len - cursor); - } + return m_cursor - cursor + right; } } @@ -912,17 +891,17 @@ PhoneticEditor::getZhuyinCursor (void) assert (parsed_len <= section_len); + gchar * sentence = NULL; + zhuyin_get_sentence (instance, &sentence); if (cursor >= parsed_len) { cursor -= parsed_len; - guint len = 0; - zhuyin_get_n_zhuyin (instance, &len); - zhuyin_cursor += len; + zhuyin_cursor += g_utf8_strlen (sentence, -1); } else { - guint16 inner_cursor = 0; - zhuyin_get_zhuyin_key_rest_offset - (instance, cursor, &inner_cursor); + size_t length = 0; + zhuyin_get_character_offset + (instance, sentence, cursor, &length); + zhuyin_cursor += length; - zhuyin_cursor += inner_cursor; cursor = 0; } @@ -938,6 +917,8 @@ PhoneticEditor::getZhuyinCursor (void) cursor = 0; } + g_free (sentence); + ++ index; } diff --git a/src/ZYZPhoneticSection.cc b/src/ZYZPhoneticSection.cc index f8bfe7d..4721885 100644 --- a/src/ZYZPhoneticSection.cc +++ b/src/ZYZPhoneticSection.cc @@ -44,9 +44,8 @@ PhoneticSection::initCandidates (zhuyin_instance_t * instance, m_instance = instance; m_cursor = cursor; - guint16 offset = 0; - zhuyin_get_zhuyin_key_rest_offset - (instance, cursor, &offset); + size_t offset = 0; + zhuyin_get_zhuyin_offset (instance, cursor, &offset); if (m_editor.m_config.candidatesAfterCursor ()) zhuyin_guess_candidates_after_cursor (m_instance, offset); @@ -102,9 +101,6 @@ PhoneticSection::fillLookupTableByPage () int PhoneticSection::selectCandidate (guint index) { - guint16 prev_pos = m_cursor, cur_pos = 0; - ChewingKeyRest * key_rest = NULL; - guint len = 0; zhuyin_get_n_candidate (m_instance, &len); @@ -114,25 +110,13 @@ PhoneticSection::selectCandidate (guint index) lookup_candidate_t * candidate = NULL; zhuyin_get_candidate (m_instance, index, &candidate); - guint16 offset = 0; - zhuyin_get_zhuyin_key_rest_offset - (m_instance, m_cursor, &offset); + size_t offset = 0; + zhuyin_get_zhuyin_offset (m_instance, m_cursor, &offset); offset = zhuyin_choose_candidate (m_instance, offset, candidate); - zhuyin_get_n_zhuyin (m_instance, &len); - - if (offset < len) { - zhuyin_get_zhuyin_key_rest (m_instance, offset, &key_rest); - zhuyin_get_zhuyin_key_rest_positions - (m_instance, key_rest, &cur_pos, NULL); - } else { - assert (offset == len); - cur_pos = zhuyin_get_parsed_input_length (m_instance); - } - - return cur_pos - prev_pos; + return offset - m_cursor; } }; |