diff --git a/scim-wnn/src/romkan.cpp b/scim-wnn/src/romkan.cpp index 29bf546..e2aaa69 100644 --- a/scim-wnn/src/romkan.cpp +++ b/scim-wnn/src/romkan.cpp @@ -77,6 +77,7 @@ */ WideString Romkan::insert(char k) { + if (k == 0) return(text); buf += k; String s; s = k; diff --git a/scim-wnn/src/scim_wnn_imengine.cpp b/scim-wnn/src/scim_wnn_imengine.cpp index 326b830..88da807 100644 --- a/scim-wnn/src/scim_wnn_imengine.cpp +++ b/scim-wnn/src/scim_wnn_imengine.cpp @@ -248,6 +248,8 @@ { } + + bool WnnInstance::process_key_event (const KeyEvent& key) { if (key.is_key_release()) return false; @@ -267,93 +269,73 @@ update_preedit_caret(m_rk.getPos()); return(true); } else - if (k_conversion_start.comp(key)) { - if (!m_rk.getTextLength()) { - return(false); + if (m_rk.getTextLength()) { + if (k_conversion_start.comp(key)) { + startConversion(m_rk.getText(true)); + alp_count ++; + show_preedit_string(); + if (m_conversion) { + update_preedit_string(wnn.getText(),wnn.getAttributeList()); + update_preedit_caret(wnn.getCaretPos()); + if (alp == -1) { + if (!m_lookup) startLookup(); + } + } + return(true); + } else + if (k_commit.comp(key)) { + commit_string(m_rk.getText(true)); + m_rk.reset(); + hide_preedit_string(); + return(true); + } else + if (k_forward.comp(key) || k_backward.comp(key)) { + k_backward.comp(key) ? m_rk.setPos(m_rk.getPos() - 1) : m_rk.setPos(m_rk.getPos() + 1); + update_preedit_string(m_rk.getText()); + update_preedit_caret(m_rk.getPos()); + return(true); + } else + if (k_backspace.comp(key)) { + m_rk.backspace(); + update_preedit_string(m_rk.getText()); + update_preedit_caret(m_rk.getPos()); + return(true); + } else + if (k_delete.comp(key)) { + m_rk.del(); + update_preedit_string(m_rk.getText()); + update_preedit_caret(m_rk.getPos()); + return(true); + } else + if (k_cancel.comp(key)) { + m_rk.reset(); + hide_preedit_string(); + return(true); + } else + if (k_convert_hiragana.comp(key)) { + m_rk.kataHira(); + update_preedit_string(m_rk.getText()); + update_preedit_caret(m_rk.getPos()); + return(true); + } else + if (k_convert_katakana.comp(key)) { + m_rk.hiraKata(); + update_preedit_string(m_rk.getText()); + update_preedit_caret(m_rk.getPos()); + return(true); } - startConversion(m_rk.getText(true)); - alp_count ++; - show_preedit_string(); - if (m_conversion) { - update_preedit_string(wnn.getText(),wnn.getAttributeList()); - update_preedit_caret(wnn.getCaretPos()); - } - if (alp == -1) { - if (!m_lookup) startLookup(); - } - return(true); - } else - if (k_commit.comp(key)) { - if (!m_rk.getTextLength()) { - return(false); - } - commit_string(m_rk.getText(true)); - m_rk.reset(); - hide_preedit_string(); - return(true); - } else - if (k_forward.comp(key) || k_backward.comp(key)) { - if (!m_rk.getTextLength()) { - return(false); - } - k_backward.comp(key) ? m_rk.setPos(m_rk.getPos() - 1) : m_rk.setPos(m_rk.getPos() + 1); - update_preedit_string(m_rk.getText()); - update_preedit_caret(m_rk.getPos()); - return(true); - } else - if (k_backspace.comp(key)) { - if (!m_rk.getTextLength()) { - return(false); - } - m_rk.backspace(); - update_preedit_string(m_rk.getText()); - update_preedit_caret(m_rk.getPos()); - return(true); - } else - if (k_delete.comp(key)) { - if (!m_rk.getTextLength()) { - return(false); - } - m_rk.del(); - update_preedit_string(m_rk.getText()); - update_preedit_caret(m_rk.getPos()); - return(true); - } else - if (k_cancel.comp(key)) { - if (!m_rk.getTextLength()) { - return(false); - } - m_rk.reset(); - hide_preedit_string(); - return(true); - } else - if (k_convert_hiragana.comp(key)) { - if (!m_rk.getTextLength()) { - return(false); - } - m_rk.kataHira(); - update_preedit_string(m_rk.getText()); - update_preedit_caret(m_rk.getPos()); - return(true); - } else - if (k_convert_katakana.comp(key)) { - if (!m_rk.getTextLength()) { - return(false); - } - m_rk.hiraKata(); - update_preedit_string(m_rk.getText()); - update_preedit_caret(m_rk.getPos()); - return(true); - } else + } if (isprint(key.code)) { if (key.mask & (SCIM_KEY_AltMask | SCIM_KEY_ControlMask)) return(false); + // �Хåե������λ��ι�Ƭ���ڡ�����ľ�����ϡ� + if ((key.code == SCIM_KEY_space) && (!m_rk.getTextLength())) return(false); show_preedit_string(); SCIM_DEBUG_IMENGINE(1) << key.get_key_string() << "\n"; update_preedit_string(m_rk.insert(key.get_ascii_code())); update_preedit_caret(m_rk.getPos()); - return true; + return(true); } - return false; + return(false); } /*! @@ -667,3 +649,5 @@ show_aux_string(); show_lookup_table(); } + +