diff options
author | Peng Wu <alexepico@gmail.com> | 2015-06-21 09:59:43 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2015-06-21 09:59:43 +0800 |
commit | 4300168afda16a42df805cdff8a0c5c192356283 (patch) | |
tree | 6aabe0d9b2b5fc533b32d83ee51e957c0974a3ef /src/ZYZZhuyinEditor.cc | |
parent | 0d92d8536cd1fe5e4e284b407dd2f98445234cac (diff) | |
download | ibus-libzhuyin-4300168afda16a42df805cdff8a0c5c192356283.tar.gz ibus-libzhuyin-4300168afda16a42df805cdff8a0c5c192356283.tar.xz ibus-libzhuyin-4300168afda16a42df805cdff8a0c5c192356283.zip |
auto commit when press space key
Diffstat (limited to 'src/ZYZZhuyinEditor.cc')
-rw-r--r-- | src/ZYZZhuyinEditor.cc | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/ZYZZhuyinEditor.cc b/src/ZYZZhuyinEditor.cc index 26fc028..d377afe 100644 --- a/src/ZYZZhuyinEditor.cc +++ b/src/ZYZZhuyinEditor.cc @@ -62,10 +62,12 @@ ZhuyinEditor::commit (void) void ZhuyinEditor::reset (void) { + m_preedit_text = ""; + PhoneticEditor::reset (); } -void +guint ZhuyinEditor::updateZhuyin (void) { const String & enhanced_text = m_text; @@ -74,6 +76,7 @@ ZhuyinEditor::updateZhuyin (void) size_t index = 0; size_t start_pos = 0, end_pos = 0; + guint pos = 0; while (end_pos != enhanced_text.size ()) { section_t type = probe_section_quick (enhanced_text, start_pos); @@ -87,6 +90,8 @@ ZhuyinEditor::updateZhuyin (void) (instance, section.c_str ()); zhuyin_guess_sentence (instance); + pos = start_pos + len; + ++index; } @@ -99,7 +104,7 @@ ZhuyinEditor::updateZhuyin (void) start_pos = end_pos; } - return; + return pos; } void @@ -194,7 +199,17 @@ ZhuyinEditor::insert (guint keyval, guint keycode, guint modifiers) insert_phonetic (m_text, m_cursor++, keyval); - updateZhuyin (); + guint len = updateZhuyin (); + + /* the space key is part of zhuyin string. */ + if (IBUS_space == keyval && + len < m_text.size () && + m_cursor == get_enhanced_text_length (m_text)) { + update (); + commit (); + return TRUE; + } + update (); return TRUE; } |