diff options
author | Peng Wu <alexepico@gmail.com> | 2015-07-28 15:59:56 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2015-07-28 16:01:31 +0800 |
commit | 6901887a0a84b4dafcad480390dd1e45acf89791 (patch) | |
tree | a9e2cf5305f8b0ce1ee54e3d19fa67c202a88d12 | |
parent | e15f6f16c4e53ab566b97db0eb37604e7204c866 (diff) | |
download | ibus-libzhuyin-6901887a0a84b4dafcad480390dd1e45acf89791.tar.gz ibus-libzhuyin-6901887a0a84b4dafcad480390dd1e45acf89791.tar.xz ibus-libzhuyin-6901887a0a84b4dafcad480390dd1e45acf89791.zip |
write processSpace method
-rw-r--r-- | src/ZYZPhoneticEditor.cc | 49 | ||||
-rw-r--r-- | src/ZYZPhoneticEditor.h | 1 | ||||
-rw-r--r-- | src/ZYZPinyinEditor.cc | 3 | ||||
-rw-r--r-- | src/ZYZZhuyinEditor.cc | 3 |
4 files changed, 52 insertions, 4 deletions
diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc index 31d0200..b4ed011 100644 --- a/src/ZYZPhoneticEditor.cc +++ b/src/ZYZPhoneticEditor.cc @@ -129,6 +129,51 @@ PhoneticEditor::processEscape (guint keyval, guint keycode, return FALSE; } +gboolean +PhoneticEditor::processSpace (guint keyval, guint keycode, + guint modifiers) +{ + if (IBUS_space != keyval && IBUS_KP_Space != keyval) + return FALSE; + + if (STATE_INPUT == m_input_state) { + if (cmshm_filter (modifiers) != 0) + return FALSE; + + if (m_text.empty ()) { + assert (is_half_english (' ')); + if (m_props.modeFullEnglish ()) { + String english; + half_english_to_full_english (keyval, english); + commit (english); + } else { + String english = ' '; + commit (english); + } + return TRUE; + } + + /* use space to show candidates. */ + assert (FALSE); + } + + if (STATE_CANDIDATE_SHOWN == m_input_state || + STATE_BUILTIN_SYMBOL_SHOWN == m_input_state || + STATE_BOPOMOFO_SYMBOL_SHOWN == m_input_state || + STATE_USER_SYMBOL_LIST_ALL == m_input_state || + STATE_USER_SYMBOL_SHOWN == m_input_state) { + if (cmshm_filter (modifiers) != 0) + return TRUE; + + selectCandidate (m_lookup_table.cursorPos ()); + + updateZhuyin (); + update (); + return TRUE; + } + + return FALSE; +} gboolean PhoneticEditor::processCommit (guint keyval, guint keycode, @@ -153,10 +198,6 @@ PhoneticEditor::processSelectCandidate (guint keyval, guint keycode, { switch (keyval) { - case IBUS_space: - case IBUS_KP_Space: - break; - case IBUS_Return: case IBUS_KP_Enter: break; diff --git a/src/ZYZPhoneticEditor.h b/src/ZYZPhoneticEditor.h index ae82615..9e178f8 100644 --- a/src/ZYZPhoneticEditor.h +++ b/src/ZYZPhoneticEditor.h @@ -61,6 +61,7 @@ public: virtual void candidateClicked (guint index, guint button, guint state); virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers); virtual gboolean processEscape (guint keyval, guint keycode, guint modifiers); + virtual gboolean processSpace (guint keyval, guint keycode, guint modifiers); virtual gboolean processCommit (guint keyval, guint keycode, guint modifiers); virtual gboolean processSelectCandidate (guint keyval, guint keycode, guint modifiers); virtual gboolean processFunctionKey (guint keyval, guint keycode, guint modifiers); diff --git a/src/ZYZPinyinEditor.cc b/src/ZYZPinyinEditor.cc index 375848e..debc2e5 100644 --- a/src/ZYZPinyinEditor.cc +++ b/src/ZYZPinyinEditor.cc @@ -226,6 +226,9 @@ PinyinEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers) if (processEscape (keyval, keycode, modifiers)) return TRUE; + if (processSpace (keyval, keycode, modifiers)) + return TRUE; + if (STATE_INPUT == m_input_state) { if (processEasySymbolKey (keyval, keycode, modifiers)) return TRUE; diff --git a/src/ZYZZhuyinEditor.cc b/src/ZYZZhuyinEditor.cc index 2590aac..bae909e 100644 --- a/src/ZYZZhuyinEditor.cc +++ b/src/ZYZZhuyinEditor.cc @@ -271,6 +271,9 @@ ZhuyinEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers) if (processEscape (keyval, keycode, modifiers)) return TRUE; + if (processSpace (keyval, keycode, modifiers)) + return TRUE; + if (STATE_INPUT == m_input_state) { if (processEasySymbolKey (keyval, keycode, modifiers)) return TRUE; |