diff options
-rw-r--r-- | src/ZYSymbols.h | 2 | ||||
-rw-r--r-- | src/ZYZPhoneticEditor.cc | 57 | ||||
-rw-r--r-- | src/ZYZPhoneticEditor.h | 3 | ||||
-rw-r--r-- | src/ZYZPinyinEditor.cc | 11 | ||||
-rw-r--r-- | src/ZYZZhuyinEditor.cc | 6 |
5 files changed, 75 insertions, 4 deletions
diff --git a/src/ZYSymbols.h b/src/ZYSymbols.h index 1aec09b..a6421b9 100644 --- a/src/ZYSymbols.h +++ b/src/ZYSymbols.h @@ -48,6 +48,8 @@ is_half_english (const char key); bool half_english_to_full_english (const char key, String & english); +#define BUILTIN_SYMBOL_TYPE "builtin" + }; #endif diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc index 643f635..dd1231c 100644 --- a/src/ZYZPhoneticEditor.cc +++ b/src/ZYZPhoneticEditor.cc @@ -27,6 +27,8 @@ #include "ZYZBuiltinSymbolSection.h" #include "ZYEnhancedText.h" #include "ZYLibZhuyin.h" +#include "ZYSymbols.h" + namespace ZY { @@ -531,5 +533,60 @@ guint PhoneticEditor::getZhuyinCursor (void) return zhuyin_cursor; } +gboolean +PhoneticEditor::insertPunct (gint ch) +{ + /* for punctuations. */ + if (is_half_punct (ch)) { + if (m_props.modeFullPunct ()) { + String choice; + assert (half_punct_to_full_punct (ch, choice)); + + String lookup; + int ch = find_lookup_key (choice); + if (ch != 0) + lookup = ch; + + insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, + lookup, choice); + } else { + String choice = ch; + insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, + "", choice); + } + + return TRUE; + } + + return FALSE; +} + +gboolean +PhoneticEditor::insertEnglish (gint ch) +{ + /* for English. */ + if (is_half_english (ch)) { + if (m_props.modeFullEnglish ()) { + String choice; + assert (half_english_to_full_english (ch, choice)); + + String lookup; + int ch = find_lookup_key (choice); + if (ch != 0) + lookup = ch; + + insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, + lookup, choice); + } else { + String choice = ch; + insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, + "", choice); + } + + return TRUE; + } + + return FALSE; +} }; diff --git a/src/ZYZPhoneticEditor.h b/src/ZYZPhoneticEditor.h index 0a8283f..4a94a18 100644 --- a/src/ZYZPhoneticEditor.h +++ b/src/ZYZPhoneticEditor.h @@ -63,6 +63,9 @@ public: virtual void updateLookupTableFast (); virtual gboolean fillLookupTableByPage (); + virtual gboolean insertPunct (gint ch); + virtual gboolean insertEnglish (gint ch); + protected: gboolean selectCandidate (guint i); gboolean selectCandidateInPage (guint i); diff --git a/src/ZYZPinyinEditor.cc b/src/ZYZPinyinEditor.cc index fe12a38..dd4adf7 100644 --- a/src/ZYZPinyinEditor.cc +++ b/src/ZYZPinyinEditor.cc @@ -30,6 +30,8 @@ using namespace ZY; +#define IS_PINYIN(ch) (('a' <= ch && ch <= 'z')||('1'<=ch && ch <= '5')) + PinyinEditor::PinyinEditor (ZhuyinProperties & props, Config & config) : PhoneticEditor (props, config) { @@ -170,8 +172,7 @@ PinyinEditor::updatePreeditText (void) gboolean PinyinEditor::insert (gint ch) { - if (('a' <= ch && ch <= 'z')|| - ('1'<=ch && ch <= '5')) { + if (IS_PINYIN (ch)) { insert_phonetic (m_text, m_cursor++, ch); updateZhuyin (); @@ -179,7 +180,11 @@ PinyinEditor::insert (gint ch) return TRUE; } - /* TODO:: handle symbols here. */ + if (insertPunct (ch)) + return TRUE; + + if (insertEnglish (ch)) + return TRUE; return FALSE; } diff --git a/src/ZYZZhuyinEditor.cc b/src/ZYZZhuyinEditor.cc index 7b34639..a0bb2eb 100644 --- a/src/ZYZZhuyinEditor.cc +++ b/src/ZYZZhuyinEditor.cc @@ -188,7 +188,11 @@ ZhuyinEditor::insert (gint ch) return TRUE; } - /* TODO:: handle symbols here. */ + if (insertPunct (ch)) + return TRUE; + + if (insertEnglish (ch)) + return TRUE; return FALSE; } |