diff options
author | Peng Wu <alexepico@gmail.com> | 2014-09-19 16:17:02 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2014-09-19 17:23:31 +0800 |
commit | bdec4e805455af2a47debb5fb2eeb32de452710f (patch) | |
tree | b818cf79d69f28313b7cc0e008ef94f699a6456d /src | |
parent | 782d9b3af46f860585419e7477c4b5fdc0c565aa (diff) | |
download | ibus-libzhuyin-bdec4e805455af2a47debb5fb2eeb32de452710f.tar.gz ibus-libzhuyin-bdec4e805455af2a47debb5fb2eeb32de452710f.tar.xz ibus-libzhuyin-bdec4e805455af2a47debb5fb2eeb32de452710f.zip |
write processEasySymbolKey method
Diffstat (limited to 'src')
-rw-r--r-- | src/ZYZPhoneticEditor.cc | 44 | ||||
-rw-r--r-- | src/ZYZPhoneticEditor.h | 6 | ||||
-rw-r--r-- | src/ZYZPinyinEditor.cc | 3 | ||||
-rw-r--r-- | src/ZYZZhuyinEditor.cc | 2 |
4 files changed, 55 insertions, 0 deletions
diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc index 098cb40..6dc1dcd 100644 --- a/src/ZYZPhoneticEditor.cc +++ b/src/ZYZPhoneticEditor.cc @@ -61,6 +61,16 @@ PhoneticEditor::PhoneticEditor (ZhuyinProperties & props, Config & config) m_phonetic_section.reset (new PhoneticSection (*this, props)); + + /* load easy symbols: easysymbol.txt */ + gchar * path = g_build_filename (g_get_user_config_dir (), + "ibus", "libzhuyin", + "easysymbol.txt", NULL); + loadEasySymbolFile (".." G_DIR_SEPARATOR_S "data" G_DIR_SEPARATOR_S + "easysymbol.txt") || + loadEasySymbolFile (path) || + loadEasySymbolFile (PKGDATADIR G_DIR_SEPARATOR_S "easysymbol.txt"); + g_free(path); } PhoneticEditor::~PhoneticEditor (void) @@ -75,6 +85,14 @@ PhoneticEditor::~PhoneticEditor (void) } gboolean +PhoneticEditor::loadEasySymbolFile(const gchar * filename) +{ + printf ("load %s.\n", filename); + gboolean retval = m_easy_symbols.loadFromFile (filename); + return retval; +} + +gboolean PhoneticEditor::processEscape (guint keyval, guint keycode, guint modifiers) { @@ -273,6 +291,32 @@ PhoneticEditor::processCandidateKey (guint keyval, guint keycode, } gboolean +PhoneticEditor::processEasySymbolKey (guint keyval, guint keycode, + guint modifiers) +{ + if (! ('A' <= keyval && keyval <= 'Z')) + return FALSE; + + String index; + index.append (1, keyval); + String symbol = m_easy_symbols.find (index); + + if ("" == symbol) + return FALSE; + + String lookup; + int ch = find_lookup_key (symbol); + if (ch != 0) + lookup = ch; + + insert_symbol (m_text, m_cursor++, BUILTIN_SYMBOL_TYPE, + lookup, symbol); + + update (); + return TRUE; +} + +gboolean PhoneticEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers) { diff --git a/src/ZYZPhoneticEditor.h b/src/ZYZPhoneticEditor.h index d42e189..4bb6f4a 100644 --- a/src/ZYZPhoneticEditor.h +++ b/src/ZYZPhoneticEditor.h @@ -25,6 +25,7 @@ #include <zhuyin.h> #include "ZYLookupTable.h" #include "ZYZEnhancedEditor.h" +#include "ZYSymbolLookup.h" #include <vector> namespace ZY { @@ -62,6 +63,7 @@ public: virtual gboolean processFunctionKey (guint keyval, guint keycode, guint modifiers); virtual gboolean processShowCandidateKey (guint keyval, guint keycode, guint modifiers); virtual gboolean processCandidateKey (guint keyval, guint keycode, guint modifiers); + virtual gboolean processEasySymbolKey (guint keyval, guint keycode, guint modifiers); virtual void updateLookupTable (); virtual void updateLookupTableFast (); virtual gboolean fillLookupTableByPage (); @@ -95,6 +97,8 @@ protected: void resizeInstances (void); + gboolean loadEasySymbolFile(const gchar * filename); + /* varibles */ LookupTable m_lookup_table; String m_buffer; @@ -118,6 +122,8 @@ protected: PhoneticSectionPtr m_phonetic_section; zhuyin_instance_vec m_instances; + + SymbolLookup m_easy_symbols; }; }; diff --git a/src/ZYZPinyinEditor.cc b/src/ZYZPinyinEditor.cc index 0a1afc9..a0c7a35 100644 --- a/src/ZYZPinyinEditor.cc +++ b/src/ZYZPinyinEditor.cc @@ -219,6 +219,9 @@ PinyinEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers) return TRUE; if (STATE_INPUT == m_input_state) { + if (processEasySymbolKey (keyval, keycode, modifiers)) + return TRUE; + if (insert (keyval)) return TRUE; diff --git a/src/ZYZZhuyinEditor.cc b/src/ZYZZhuyinEditor.cc index 338bc55..b32e1e1 100644 --- a/src/ZYZZhuyinEditor.cc +++ b/src/ZYZZhuyinEditor.cc @@ -227,6 +227,8 @@ ZhuyinEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers) return TRUE; if (STATE_INPUT == m_input_state) { + if (processEasySymbolKey (keyval, keycode, modifiers)) + return TRUE; if (insert (keyval)) return TRUE; |