diff --git a/scim-wnn/src/preeditor.cpp b/scim-wnn/src/preeditor.cpp index 1a1e661..a9335b9 100644 --- a/scim-wnn/src/preeditor.cpp +++ b/scim-wnn/src/preeditor.cpp @@ -71,21 +71,6 @@ } -/*! - \fn PreEditor::insert(char k) - */ -WideString PreEditor::insert(char k) -{ - if (k == 0) return(text); - String s; - s = k; - text = text.substr(0,pos) + utf8_mbstowcs(s) + text.substr(pos); - pos ++; - return(getText()); -} - - - /*! \fn PreEditor::reset() @@ -245,3 +230,19 @@ return(false); } + + +/*! + \fn PreEditor::inputEvent(const KeyEvent &key) + */ +bool PreEditor::inputEvent(const KeyEvent &key) +{ + if (isprint(key.code)){ + String s; + s = key.get_ascii_code(); + text = text.substr(0,pos) + utf8_mbstowcs(s) + text.substr(pos); + pos ++; + return(true); + } + return(false); +} diff --git a/scim-wnn/src/preeditor.h b/scim-wnn/src/preeditor.h index b9788a9..c14c849 100644 --- a/scim-wnn/src/preeditor.h +++ b/scim-wnn/src/preeditor.h @@ -42,7 +42,6 @@ ~PreEditor(); virtual void clear(); - virtual WideString insert(char k); int getPos(); virtual void setPos(int p); int getTextLength(); @@ -59,6 +58,7 @@ static void convHanZen(WideString &t); static void convZenHan(WideString &t); virtual bool cancelEvent(); + virtual bool inputEvent(const KeyEvent &key); protected: static WideString text; diff --git a/scim-wnn/src/romkan.cpp b/scim-wnn/src/romkan.cpp index 1f120c9..50a17e9 100644 --- a/scim-wnn/src/romkan.cpp +++ b/scim-wnn/src/romkan.cpp @@ -307,3 +307,17 @@ } return(false); } + + +/*! + \fn Romkan::inputEvent(const KeyEvent &key) + */ +bool Romkan::inputEvent(const KeyEvent &key) +{ + if (isprint(key.code) && (!key.is_alt_down()) && (!key.is_control_down())) { + if (key.get_ascii_code() == ' ') return(false); + insert(key.get_ascii_code()); + return(true); + } + return(false); +} diff --git a/scim-wnn/src/romkan.h b/scim-wnn/src/romkan.h index f726019..79bd31f 100644 --- a/scim-wnn/src/romkan.h +++ b/scim-wnn/src/romkan.h @@ -39,7 +39,6 @@ ~Romkan(); virtual void clear(); - virtual WideString insert(char k); virtual void setPos(int p); virtual void reset(); virtual WideString getText(bool hosei = false); @@ -50,9 +49,11 @@ virtual bool keyEventHook(const KeyEvent &key); virtual String getModeName(); virtual bool cancelEvent(); + virtual bool inputEvent(const KeyEvent &key); protected: WideString eval(); + WideString insert(char k); protected: String buf; diff --git a/scim-wnn/src/scim_wnn_imengine.cpp b/scim-wnn/src/scim_wnn_imengine.cpp index 1c03950..4590136 100644 --- a/scim-wnn/src/scim_wnn_imengine.cpp +++ b/scim-wnn/src/scim_wnn_imengine.cpp @@ -351,13 +351,8 @@ updatePreEditor(); return(true); } - if (isprint(key.code)) { - if (key.mask & (SCIM_KEY_AltMask | SCIM_KEY_ControlMask)) return(false); - // �Хåե������λ��ι�Ƭ���ڡ�����ľ�����ϡ� - if ((key.code == SCIM_KEY_space) && (!m_preeditor->getTextLength())) return(false); - show_preedit_string(); - SCIM_DEBUG_IMENGINE(1) << key.get_key_string() << "\n"; - m_preeditor->insert(key.get_ascii_code()); + + if (m_preeditor->inputEvent(key)) { updatePreEditor(); return(true); }