From e07ea48d15e995d82ebe0ca9028a153fb93cb674 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Tue, 20 Sep 2016 14:32:41 +0800 Subject: update PhoneticEditor --- src/ZYZPhoneticEditor.cc | 49 ++++++++++++------------------------------------ src/ZYZPhoneticEditor.h | 3 +-- src/ZYZPinyinEditor.cc | 8 +------- src/ZYZZhuyinEditor.cc | 8 +------- 4 files changed, 15 insertions(+), 53 deletions(-) diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc index 184ab90..f82a4b2 100644 --- a/src/ZYZPhoneticEditor.cc +++ b/src/ZYZPhoneticEditor.cc @@ -149,14 +149,14 @@ PhoneticEditor::processSpace (guint keyval, guint keycode, return FALSE; if (m_text.empty ()) { - assert (is_half_english (' ')); + assert (is_special_symbol (' ')); if (m_props.modeFullWidth ()) { - String english; - half_english_to_full_english (keyval, english); - commit (english); + String symbol; + convert_special_symbol (keyval, symbol); + commit (symbol); } else { - String english = ' '; - commit (english); + String symbol = ' '; + commit (symbol); } return TRUE; } @@ -956,13 +956,13 @@ PhoneticEditor::getZhuyinCursor (void) } gboolean -PhoneticEditor::insertPunct (guint keyval, guint keycode, guint modifiers) +PhoneticEditor::insertSymbol (guint keyval, guint keycode, guint modifiers) { - /* for punctuations. */ - if (is_half_punct (keyval)) { + /* for symbols. */ + if (is_full_width_symbol (keyval)) { if (m_props.modeFullWidth () || modifiers & IBUS_SHIFT_MASK) { String choice; - assert (half_punct_to_full_punct (keyval, choice)); + assert (convert_full_width_symbol (keyval, choice)); String lookup; int ch = find_lookup_key (choice); @@ -973,34 +973,9 @@ PhoneticEditor::insertPunct (guint keyval, guint keycode, guint modifiers) lookup, choice); } else { String choice = (gchar) keyval; - insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, - "", choice); - } - - return TRUE; - } + if (is_special_symbol (keyval)) + convert_special_symbol (keyval, choice); - return FALSE; -} - -gboolean -PhoneticEditor::insertEnglish (guint keyval, guint keycode, guint modifiers) -{ - /* for English. */ - if (is_half_english (keyval)) { - if (m_props.modeFullWidth () || modifiers & IBUS_SHIFT_MASK) { - String choice; - assert (half_english_to_full_english (keyval, choice)); - - String lookup; - int ch = find_lookup_key (choice); - if (ch != 0) - lookup = (gchar) ch; - - insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, - lookup, choice); - } else { - String choice = (gchar) keyval; insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, "", choice); } diff --git a/src/ZYZPhoneticEditor.h b/src/ZYZPhoneticEditor.h index 90f00e7..7aa6d98 100644 --- a/src/ZYZPhoneticEditor.h +++ b/src/ZYZPhoneticEditor.h @@ -74,8 +74,7 @@ public: virtual void updateLookupTableLabel (); virtual gboolean fillLookupTableByPage (); - virtual gboolean insertPunct (guint keyval, guint keycode, guint modifiers); - virtual gboolean insertEnglish (guint keyval, guint keycode, guint modifiers); + virtual gboolean insertSymbol (guint keyval, guint keycode, guint modifiers); virtual gboolean insertNumbers (guint keyval, guint keycode, guint modifiers); protected: diff --git a/src/ZYZPinyinEditor.cc b/src/ZYZPinyinEditor.cc index 67889a8..5b5e9df 100644 --- a/src/ZYZPinyinEditor.cc +++ b/src/ZYZPinyinEditor.cc @@ -212,13 +212,7 @@ PinyinEditor::insert (guint keyval, guint keycode, guint modifiers) return TRUE; } - if (insertPunct (keyval, keycode, modifiers)) { - updateZhuyin (); - update (); - return TRUE; - } - - if (insertEnglish (keyval, keycode, modifiers)) { + if (insertSymbol (keyval, keycode, modifiers)) { updateZhuyin (); update (); return TRUE; diff --git a/src/ZYZZhuyinEditor.cc b/src/ZYZZhuyinEditor.cc index 60ba093..55e29e0 100644 --- a/src/ZYZZhuyinEditor.cc +++ b/src/ZYZZhuyinEditor.cc @@ -259,13 +259,7 @@ ZhuyinEditor::insert (guint keyval, guint keycode, guint modifiers) return TRUE; } - if (insertPunct (keyval, keycode, modifiers)) { - updateZhuyin (); - update (); - return TRUE; - } - - if (insertEnglish (keyval, keycode, modifiers)) { + if (insertSymbol (keyval, keycode, modifiers)) { updateZhuyin (); update (); return TRUE; -- cgit