summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2015-08-07 14:23:54 +0800
committerPeng Wu <alexepico@gmail.com>2015-08-07 14:41:51 +0800
commit13bc6023c48809b242945c89ff63a27545e3912f (patch)
treee577d1db855976b394668c84fc5924a4aa0a22ed
parent828fa4586307d0886b714aad01ae99512ed9dcdf (diff)
downloadibus-libzhuyin-13bc6023c48809b242945c89ff63a27545e3912f.tar.gz
ibus-libzhuyin-13bc6023c48809b242945c89ff63a27545e3912f.tar.xz
ibus-libzhuyin-13bc6023c48809b242945c89ff63a27545e3912f.zip
fixes processSpace method
-rw-r--r--src/ZYZPhoneticEditor.cc7
-rw-r--r--src/ZYZPinyinEditor.cc24
-rw-r--r--src/ZYZPinyinEditor.h1
-rw-r--r--src/ZYZZhuyinEditor.cc50
-rw-r--r--src/ZYZZhuyinEditor.h1
5 files changed, 77 insertions, 6 deletions
diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc
index 0baa17c..0672706 100644
--- a/src/ZYZPhoneticEditor.cc
+++ b/src/ZYZPhoneticEditor.cc
@@ -153,12 +153,7 @@ PhoneticEditor::processSpace (guint keyval, guint keycode,
return TRUE;
}
- if (m_config.spaceShowCandidates ()) {
- /* use space to show candidates. */
- prepareCandidates ();
- update ();
- return TRUE;
- } else {
+ if (!m_config.spaceShowCandidates ()) {
return insert (keyval, keycode, modifiers);
}
}
diff --git a/src/ZYZPinyinEditor.cc b/src/ZYZPinyinEditor.cc
index 4d7abe0..33173ae 100644
--- a/src/ZYZPinyinEditor.cc
+++ b/src/ZYZPinyinEditor.cc
@@ -234,6 +234,30 @@ PinyinEditor::insert (guint keyval, guint keycode, guint modifiers)
}
gboolean
+PinyinEditor::processSpace (guint keyval, guint keycode, guint modifiers)
+{
+ if (IBUS_space != keyval && IBUS_KP_Space != keyval)
+ return FALSE;
+
+ if (PhoneticEditor::processSpace (keyval, keycode, modifiers))
+ return TRUE;
+
+ if (STATE_INPUT == m_input_state) {
+ if (cmshm_filter (modifiers) != 0)
+ return FALSE;
+
+ if (m_config.spaceShowCandidates ()) {
+ /* use space to show candidates. */
+ prepareCandidates ();
+ update ();
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+gboolean
PinyinEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers)
{
modifiers &= (IBUS_SHIFT_MASK |
diff --git a/src/ZYZPinyinEditor.h b/src/ZYZPinyinEditor.h
index 0693947..dd6184e 100644
--- a/src/ZYZPinyinEditor.h
+++ b/src/ZYZPinyinEditor.h
@@ -36,6 +36,7 @@ public:
virtual ~PinyinEditor (void);
protected:
+ gboolean processSpace (guint keyval, guint keycode, guint modifiers);
gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers);
virtual void updatePreeditText ();
diff --git a/src/ZYZZhuyinEditor.cc b/src/ZYZZhuyinEditor.cc
index a6aa8dd..9fb2709 100644
--- a/src/ZYZZhuyinEditor.cc
+++ b/src/ZYZZhuyinEditor.cc
@@ -280,6 +280,56 @@ ZhuyinEditor::insert (guint keyval, guint keycode, guint modifiers)
}
gboolean
+ZhuyinEditor::processSpace (guint keyval, guint keycode, guint modifiers)
+{
+ if (IBUS_space != keyval && IBUS_KP_Space != keyval)
+ return FALSE;
+
+ if (PhoneticEditor::processSpace (keyval, keycode, modifiers))
+ return TRUE;
+
+ String new_text = m_text;
+ guint cursor = 0;
+
+ if (STATE_INPUT == m_input_state) {
+ if (cmshm_filter (modifiers) != 0)
+ return FALSE;
+
+ /* use space to show candidates. */
+ if (m_config.spaceShowCandidates ()) {
+ size_t index = 0;
+ size_t start_pos = 0, end_pos = 0;
+
+ /* detect whether the space key is part of zhuyin input. */
+ insert_phonetic (new_text, m_cursor, ' ');
+
+ probe_section_start (new_text, m_cursor,
+ cursor, index, start_pos);
+
+ section_t type = probe_section_quick (new_text, start_pos);
+
+ if (PHONETIC_SECTION == type) {
+ String section;
+ get_phonetic_section (new_text, start_pos, end_pos, section);
+
+ zhuyin_parse_more_chewings (m_instance, section.c_str ());
+ size_t parsed_len = zhuyin_get_parsed_input_length (m_instance);
+
+ /* part of the zhuyin string. */
+ if (cursor < parsed_len)
+ return insert (keyval, keycode, modifiers);
+ }
+
+ prepareCandidates ();
+ update ();
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+gboolean
ZhuyinEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers)
{
modifiers &= (IBUS_SHIFT_MASK |
diff --git a/src/ZYZZhuyinEditor.h b/src/ZYZZhuyinEditor.h
index 40920d2..c2ff97f 100644
--- a/src/ZYZZhuyinEditor.h
+++ b/src/ZYZZhuyinEditor.h
@@ -36,6 +36,7 @@ public:
virtual ~ZhuyinEditor (void);
protected:
+ gboolean processSpace (guint keyval, guint keycode, guint modifiers);
gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers);
virtual void updatePreeditText ();