diff options
-rw-r--r-- | src/ZYZPhoneticEditor.h | 2 | ||||
-rw-r--r-- | src/ZYZPinyinEditor.cc | 20 | ||||
-rw-r--r-- | src/ZYZPinyinEditor.h | 2 | ||||
-rw-r--r-- | src/ZYZZhuyinEditor.cc | 20 | ||||
-rw-r--r-- | src/ZYZZhuyinEditor.h | 2 |
5 files changed, 29 insertions, 17 deletions
diff --git a/src/ZYZPhoneticEditor.h b/src/ZYZPhoneticEditor.h index 6c6b2a0..2a05bfc 100644 --- a/src/ZYZPhoneticEditor.h +++ b/src/ZYZPhoneticEditor.h @@ -84,7 +84,7 @@ protected: void commit (const gchar *str); /* pure virtual functions */ - virtual gboolean insert (gint ch) = 0; + virtual gboolean insert (guint keyval, guint keycode, guint modifiers) = 0; virtual gboolean removeCharBefore (void); virtual gboolean removeCharAfter (void); virtual gboolean moveCursorLeft (void); diff --git a/src/ZYZPinyinEditor.cc b/src/ZYZPinyinEditor.cc index aac58c0..4206713 100644 --- a/src/ZYZPinyinEditor.cc +++ b/src/ZYZPinyinEditor.cc @@ -173,29 +173,35 @@ PinyinEditor::updatePreeditText (void) } gboolean -PinyinEditor::insert (gint ch) +PinyinEditor::insert (guint keyval, guint keycode, guint modifiers) { - if (IS_PINYIN (ch)) { - insert_phonetic (m_text, m_cursor++, ch); + /* let client applications to handle shortcut key event */ + modifiers = cmshm_filter (modifiers); + + if (modifiers != 0 && m_text.empty ()) + return FALSE; + + if (IS_PINYIN (keyval)) { + insert_phonetic (m_text, m_cursor++, keyval); updateZhuyin (); update (); return TRUE; } - if (insertPunct (ch)) { + if (insertPunct (keyval)) { updateZhuyin (); update (); return TRUE; } - if (insertEnglish (ch)) { + if (insertEnglish (keyval)) { updateZhuyin (); update (); return TRUE; } - if (insertNumbers (ch)) { + if (insertNumbers (keyval)) { updateZhuyin (); update (); return TRUE; @@ -225,7 +231,7 @@ PinyinEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers) if (processUserSymbolKey (keyval, keycode, modifiers)) return TRUE; - if (insert (keyval)) + if (insert (keyval, keycode, modifiers)) return TRUE; if (processEnter (keyval, keycode, modifiers)) diff --git a/src/ZYZPinyinEditor.h b/src/ZYZPinyinEditor.h index 58e4c0b..0693947 100644 --- a/src/ZYZPinyinEditor.h +++ b/src/ZYZPinyinEditor.h @@ -45,7 +45,7 @@ protected: void commit (); void reset (); - gboolean insert (gint ch); + gboolean insert (guint keyval, guint keycode, guint modifiers); protected: String m_preedit_text; diff --git a/src/ZYZZhuyinEditor.cc b/src/ZYZZhuyinEditor.cc index f71b52e..14049c4 100644 --- a/src/ZYZZhuyinEditor.cc +++ b/src/ZYZZhuyinEditor.cc @@ -178,32 +178,38 @@ ZhuyinEditor::updatePreeditText (void) } gboolean -ZhuyinEditor::insert (gint ch) +ZhuyinEditor::insert (guint keyval, guint keycode, guint modifiers) { + /* let client applications to handle shortcut key event */ + modifiers = cmshm_filter (modifiers); + + if (modifiers != 0 && m_text.empty ()) + return FALSE; + gchar ** symbols = NULL; - if (zhuyin_in_chewing_keyboard (m_instance, ch, &symbols)) { + if (zhuyin_in_chewing_keyboard (m_instance, keyval, &symbols)) { g_strfreev (symbols); - insert_phonetic (m_text, m_cursor++, ch); + insert_phonetic (m_text, m_cursor++, keyval); updateZhuyin (); update (); return TRUE; } - if (insertPunct (ch)) { + if (insertPunct (keyval)) { updateZhuyin (); update (); return TRUE; } - if (insertEnglish (ch)) { + if (insertEnglish (keyval)) { updateZhuyin (); update (); return TRUE; } - if (insertNumbers (ch)) { + if (insertNumbers (keyval)) { updateZhuyin (); update (); return TRUE; @@ -233,7 +239,7 @@ ZhuyinEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers) if (processUserSymbolKey (keyval, keycode, modifiers)) return TRUE; - if (insert (keyval)) + if (insert (keyval, keycode, modifiers)) return TRUE; if (processEnter (keyval, keycode, modifiers)) diff --git a/src/ZYZZhuyinEditor.h b/src/ZYZZhuyinEditor.h index bbe4b39..40920d2 100644 --- a/src/ZYZZhuyinEditor.h +++ b/src/ZYZZhuyinEditor.h @@ -45,7 +45,7 @@ protected: void commit (); void reset (); - gboolean insert (gint ch); + gboolean insert (guint keyval, guint keycode, guint modifiers); protected: String m_preedit_text; |