From 4d768fd5f8cb47eca8ad03f45bde9b4acba7da4c Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 15 Oct 2018 16:33:36 +0800 Subject: fixes processSpace method --- src/ZYZPhoneticEditor.cc | 3 +++ src/ZYZPinyinEditor.cc | 4 +++- src/ZYZZhuyinEditor.cc | 41 ++++++++++++++++++++++++----------------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc index 77307c3..bf337f7 100644 --- a/src/ZYZPhoneticEditor.cc +++ b/src/ZYZPhoneticEditor.cc @@ -161,9 +161,12 @@ PhoneticEditor::processSpace (guint keyval, guint keycode, return TRUE; } +#if 0 if (!m_config.spaceShowCandidates ()) { return insert (keyval, keycode, modifiers); } +#endif + return FALSE; } if (STATE_CANDIDATE_SHOWN == m_input_state || diff --git a/src/ZYZPinyinEditor.cc b/src/ZYZPinyinEditor.cc index 05e1c92..591518e 100644 --- a/src/ZYZPinyinEditor.cc +++ b/src/ZYZPinyinEditor.cc @@ -228,7 +228,9 @@ PinyinEditor::processSpace (guint keyval, guint keycode, guint modifiers) if (cmshm_filter (modifiers) != 0) return FALSE; - if (m_config.spaceShowCandidates ()) { + if (!m_config.spaceShowCandidates ()) { + return insert (keyval, keycode, modifiers); + } else { /* use space to show candidates. */ prepareCandidates (); update (); diff --git a/src/ZYZZhuyinEditor.cc b/src/ZYZZhuyinEditor.cc index d8e7b84..2c1ce9e 100644 --- a/src/ZYZZhuyinEditor.cc +++ b/src/ZYZZhuyinEditor.cc @@ -242,31 +242,38 @@ ZhuyinEditor::processSpace (guint keyval, guint keycode, guint modifiers) if (cmshm_filter (modifiers) != 0) return FALSE; - /* use space to show candidates. */ - if (m_config.spaceShowCandidates ()) { - size_t index = 0; - size_t start_pos = 0, end_pos = 0; + size_t index = 0; + size_t start_pos = 0, end_pos = 0; - /* detect whether the space key is part of zhuyin input. */ - insert_phonetic (new_text, m_cursor, ' '); + /* detect whether the space key is part of zhuyin input. */ + insert_phonetic (new_text, m_cursor, ' '); - probe_section_start (new_text, m_cursor, - cursor, index, start_pos); + probe_section_start (new_text, m_cursor, + cursor, index, start_pos); - section_t type = probe_section_quick (new_text, start_pos); + section_t type = probe_section_quick (new_text, start_pos); + + if (PHONETIC_SECTION == type) { + String section; + get_phonetic_section (new_text, start_pos, end_pos, section); - if (PHONETIC_SECTION == type) { - String section; - get_phonetic_section (new_text, start_pos, end_pos, section); + zhuyin_parse_more_chewings (m_instance, section.c_str ()); + size_t parsed_len = zhuyin_get_parsed_input_length (m_instance); - zhuyin_parse_more_chewings (m_instance, section.c_str ()); - size_t parsed_len = zhuyin_get_parsed_input_length (m_instance); + /* part of the zhuyin string. */ + if (cursor < parsed_len) { + return insert (keyval, keycode, modifiers); + } else if (!m_config.spaceShowCandidates ()) { + insertSymbol (keyval); - /* part of the zhuyin string. */ - if (cursor < parsed_len) - return insert (keyval, keycode, modifiers); + updateZhuyin (); + update (); + return TRUE; } + } + /* use space to show candidates. */ + if (m_config.spaceShowCandidates ()) { prepareCandidates (); update (); return TRUE; -- cgit