summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2014-06-11 17:04:33 +0800
committerPeng Wu <alexepico@gmail.com>2014-06-11 17:04:33 +0800
commite6964ee074d6cb8ab05d0b9b4b316cf461a962d0 (patch)
tree60db309b7b717b1ee855fd15fe3ec7cbd56577cb
parenta677b9400cd6aba419bbf6b4840b64b8a2e192f5 (diff)
downloadibus-libzhuyin-e6964ee074d6cb8ab05d0b9b4b316cf461a962d0.tar.gz
ibus-libzhuyin-e6964ee074d6cb8ab05d0b9b4b316cf461a962d0.tar.xz
ibus-libzhuyin-e6964ee074d6cb8ab05d0b9b4b316cf461a962d0.zip
write codes for built-in symbols
-rw-r--r--src/ZYSymbols.h2
-rw-r--r--src/ZYZPhoneticEditor.cc57
-rw-r--r--src/ZYZPhoneticEditor.h3
-rw-r--r--src/ZYZPinyinEditor.cc11
-rw-r--r--src/ZYZZhuyinEditor.cc6
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;
}