summaryrefslogtreecommitdiffstats
path: root/src/ZYZPhoneticEditor.cc
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2014-09-19 16:17:02 +0800
committerPeng Wu <alexepico@gmail.com>2014-09-19 17:23:31 +0800
commitbdec4e805455af2a47debb5fb2eeb32de452710f (patch)
treeb818cf79d69f28313b7cc0e008ef94f699a6456d /src/ZYZPhoneticEditor.cc
parent782d9b3af46f860585419e7477c4b5fdc0c565aa (diff)
downloadibus-libzhuyin-bdec4e805455af2a47debb5fb2eeb32de452710f.tar.gz
ibus-libzhuyin-bdec4e805455af2a47debb5fb2eeb32de452710f.tar.xz
ibus-libzhuyin-bdec4e805455af2a47debb5fb2eeb32de452710f.zip
write processEasySymbolKey method
Diffstat (limited to 'src/ZYZPhoneticEditor.cc')
-rw-r--r--src/ZYZPhoneticEditor.cc44
1 files changed, 44 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)
{