diff options
author | Peng Wu <alexepico@gmail.com> | 2014-07-14 17:04:25 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2014-07-14 17:04:25 +0800 |
commit | e4a5aecca0d5a30571cf66ee2840570245af5e97 (patch) | |
tree | 26406779f31093ced51b46a0d52cc5c9b0b382ab | |
parent | 5f2e3140722ff81a6b9c5f925a1e0aa41918fafc (diff) | |
download | ibus-libzhuyin-e4a5aecca0d5a30571cf66ee2840570245af5e97.tar.gz ibus-libzhuyin-e4a5aecca0d5a30571cf66ee2840570245af5e97.tar.xz ibus-libzhuyin-e4a5aecca0d5a30571cf66ee2840570245af5e97.zip |
write always input numbers option
-rw-r--r-- | src/ZYZPhoneticEditor.cc | 43 | ||||
-rw-r--r-- | src/ZYZPhoneticEditor.h | 5 | ||||
-rw-r--r-- | src/ZYZPinyinEditor.cc | 16 | ||||
-rw-r--r-- | src/ZYZZhuyinEditor.cc | 8 |
4 files changed, 66 insertions, 6 deletions
diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc index f6217a2..7a09c69 100644 --- a/src/ZYZPhoneticEditor.cc +++ b/src/ZYZPhoneticEditor.cc @@ -630,7 +630,7 @@ PhoneticEditor::getZhuyinCursor (void) } gboolean -PhoneticEditor::insertPunct (gint ch) +PhoneticEditor::insertPunct (guint ch) { /* for punctuations. */ if (is_half_punct (ch)) { @@ -658,7 +658,7 @@ PhoneticEditor::insertPunct (gint ch) } gboolean -PhoneticEditor::insertEnglish (gint ch) +PhoneticEditor::insertEnglish (guint ch) { /* for English. */ if (is_half_english (ch)) { @@ -686,6 +686,45 @@ PhoneticEditor::insertEnglish (gint ch) } gboolean +PhoneticEditor::insertNumbers (guint ch) +{ + /* for input pad numbers. */ + static const guint keyvals[] = {IBUS_KP_Delete, IBUS_KP_Insert, + IBUS_KP_End, IBUS_KP_Down, + IBUS_KP_Next, IBUS_KP_Left, + IBUS_KP_Begin, IBUS_KP_Right, + IBUS_KP_Home, IBUS_KP_Up, + IBUS_KP_Prior}; + + static const char numbers[] = {'.', '0', + '1', '2', + '3', '4', + '5', '6', + '7', '8', + '9'}; + + assert (G_N_ELEMENTS (keyvals) == G_N_ELEMENTS (numbers)); + + if (!m_config.alwaysInputNumbers ()) + return FALSE; + + for (size_t i = 0; i < G_N_ELEMENTS (keyvals); ++i) { + if (keyvals[i] == ch) { + String choice; + choice += numbers[i]; + + insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, + "", choice); + + return TRUE; + } + } + + return FALSE; +} + + +gboolean PhoneticEditor::prepareCandidates (void) { /* decrement the cursor variable to calculate the zhuyin cursor. */ diff --git a/src/ZYZPhoneticEditor.h b/src/ZYZPhoneticEditor.h index 30d34ec..d42e189 100644 --- a/src/ZYZPhoneticEditor.h +++ b/src/ZYZPhoneticEditor.h @@ -66,8 +66,9 @@ public: virtual void updateLookupTableFast (); virtual gboolean fillLookupTableByPage (); - virtual gboolean insertPunct (gint ch); - virtual gboolean insertEnglish (gint ch); + virtual gboolean insertPunct (guint ch); + virtual gboolean insertEnglish (guint ch); + virtual gboolean insertNumbers (guint ch); protected: gboolean prepareCandidates (void); diff --git a/src/ZYZPinyinEditor.cc b/src/ZYZPinyinEditor.cc index 44e29c6..0a1afc9 100644 --- a/src/ZYZPinyinEditor.cc +++ b/src/ZYZPinyinEditor.cc @@ -183,11 +183,23 @@ PinyinEditor::insert (gint ch) return TRUE; } - if (insertPunct (ch)) + if (insertPunct (ch)) { + updateZhuyin (); + update (); return TRUE; + } - if (insertEnglish (ch)) + if (insertEnglish (ch)) { + updateZhuyin (); + update (); return TRUE; + } + + if (insertNumbers (ch)) { + updateZhuyin (); + update (); + return TRUE; + } return FALSE; } diff --git a/src/ZYZZhuyinEditor.cc b/src/ZYZZhuyinEditor.cc index 66ab411..338bc55 100644 --- a/src/ZYZZhuyinEditor.cc +++ b/src/ZYZZhuyinEditor.cc @@ -192,11 +192,19 @@ ZhuyinEditor::insert (gint ch) } if (insertPunct (ch)) { + updateZhuyin (); update (); return TRUE; } if (insertEnglish (ch)) { + updateZhuyin (); + update (); + return TRUE; + } + + if (insertNumbers (ch)) { + updateZhuyin (); update (); return TRUE; } |