diff --git a/scim-wnn/src/preeditor.cpp b/scim-wnn/src/preeditor.cpp index 17d3677..f855805 100644 --- a/scim-wnn/src/preeditor.cpp +++ b/scim-wnn/src/preeditor.cpp @@ -256,3 +256,13 @@ { return(String("PreEditor")); } + + +/*! + \fn PreEditor::setText(const WideString &t) + */ +void PreEditor::setText(const WideString &t) +{ + text = t; +} + diff --git a/scim-wnn/src/preeditor.h b/scim-wnn/src/preeditor.h index 243fb45..cfd766c 100644 --- a/scim-wnn/src/preeditor.h +++ b/scim-wnn/src/preeditor.h @@ -62,6 +62,7 @@ virtual bool inputEvent(const KeyEvent &key); virtual String getName(); virtual String getPropertyName() {return(String("PreEditor"));}; + virtual void setText(const WideString &t); protected: static WideString text; diff --git a/scim-wnn/src/romkan.cpp b/scim-wnn/src/romkan.cpp index 4a3297d..2353192 100644 --- a/scim-wnn/src/romkan.cpp +++ b/scim-wnn/src/romkan.cpp @@ -188,6 +188,15 @@ mode = ROMA; } +/*! + \fn PreEditor::setText(const WideString &t) + */ +void Romkan::setText(const WideString &t) +{ + text = t; + buf.clear(); +} + /*! \fn Romkan::getText(bool hosei) diff --git a/scim-wnn/src/romkan.h b/scim-wnn/src/romkan.h index 1c8cc88..fb253b6 100644 --- a/scim-wnn/src/romkan.h +++ b/scim-wnn/src/romkan.h @@ -53,6 +53,7 @@ virtual bool inputEvent(const KeyEvent &key); virtual String getName(); virtual String getPropertyName() {return(String("Romkan"));}; + virtual void setText(const WideString &t); protected: WideString eval(); diff --git a/scim-wnn/src/scim_wnn_def.h b/scim-wnn/src/scim_wnn_def.h index 243c8fd..ce090b1 100644 --- a/scim-wnn/src/scim_wnn_def.h +++ b/scim-wnn/src/scim_wnn_def.h @@ -62,6 +62,8 @@ #define SCIM_DEFAULT_WNN_KEY_CONVERSION_IKEIJI "Shift+F8" #define SCIM_CONFIG_WNN_KEY_CONVERSION_RENSOU "/IMEngine/Wnn/Key/ConversionRensou" #define SCIM_DEFAULT_WNN_KEY_CONVERSION_RENSOU "Shift+F9" +#define SCIM_CONFIG_WNN_KEY_SELECT_YOSOKU "/IMEngine/Wnn/Key/SelectYosoku" +#define SCIM_DEFAULT_WNN_KEY_SELECT_YOSOKU "Tab" #define SCIM_CONFIG_WNN_ALP "/IMEngine/Wnn/AutoLookupPopup" #define SCIM_DEFAULT_WNN_ALP 3 diff --git a/scim-wnn/src/scim_wnn_imengine.cpp b/scim-wnn/src/scim_wnn_imengine.cpp index 50d375a..fab3409 100644 --- a/scim-wnn/src/scim_wnn_imengine.cpp +++ b/scim-wnn/src/scim_wnn_imengine.cpp @@ -197,6 +197,7 @@ void WnnInstance::init() { m_conversion = false; + m_yosoku = false; m_lookup = false; // @todo if connected to jserver, should disconnect this. @@ -270,6 +271,9 @@ scim_string_to_key_list(k_conversion_ikeiji, _scim_config->read(String(SCIM_CONFIG_WNN_KEY_CONVERSION_IKEIJI), String(SCIM_DEFAULT_WNN_KEY_CONVERSION_IKEIJI))); + scim_string_to_key_list(k_select_yosoku, + _scim_config->read(String(SCIM_CONFIG_WNN_KEY_SELECT_YOSOKU), + String(SCIM_DEFAULT_WNN_KEY_SELECT_YOSOKU))); // �����ǰ�����³���Ƥ������� @@ -383,8 +387,9 @@ bool WnnInstance::process_key_event (const KeyEvent& key) { - if (key.is_key_release()) return false; + if (key.is_key_release()) return(false); if (m_conversion) return(process_conversion_key_event(key)); + else if (m_yosoku) return(process_yosoku_key_event(key)); else return(process_preedit_key_event(key)); } @@ -432,6 +437,11 @@ m_preeditor->hiraKata(); updatePreEditor(); return(true); + } else + if (k_select_yosoku.comp(key) && yosoku) { + if ((m_convList.kType == YOSOKU) && (m_convList.count)) { + return(process_yosoku_key_event(key)); + } } } @@ -604,6 +614,42 @@ } + +/*! + \fn WnnInstance::process_yosoku_key_event(const KeyEvent &key) + */ +bool WnnInstance::process_yosoku_key_event(const KeyEvent &key) +{ + if (!m_yosoku) { + m_yosoku = true; + update_preedit_string(m_convList.kouho.at(m_convList.pos)); + update_preedit_caret(m_convList.kouho.at(m_convList.pos).length()); + show_preedit_string(); + return(true); + } + + if (k_conversion_next.comp(key) || k_conversion_prev.comp(key) || k_select_yosoku.comp(key)) { + k_conversion_prev.comp(key) ? m_convList.pos --: m_convList.pos ++; + if (m_convList.pos >= m_convList.count) m_convList.pos = 0; + else if (m_convList.pos < 0) m_convList.pos = m_convList.count - 1; + select_candidate((unsigned int)m_convList.pos); + return(true); + } else + if (k_cancel.comp(key) || k_backspace.comp(key)) { + m_yosoku = false; + updatePreEditor(); + return(true); + } + if (!key.get_ascii_code()) return(true); + m_yosoku = false; + commit_string(m_convList.kouho.at(m_convList.pos)); + m_preeditor->reset(); + updatePreEditor(); + return(process_preedit_key_event(key)); +} + + + void WnnInstance::move_preedit_caret (unsigned int pos) { //if (!m_conversion) m_preeditor->setPos(pos); @@ -620,9 +666,12 @@ if (m_convList.kType != YOSOKU) { update_preedit_string(wnn.getText(),wnn.getAttributeList()); update_preedit_caret(wnn.getCaretPos()); - m_lookup_table.set_cursor_pos(m_convList.pos); - update_lookup_table(m_lookup_table); + } else { + update_preedit_string(m_convList.kouho.at(m_convList.pos)); + update_preedit_caret(m_convList.kouho.at(m_convList.pos).length()); } + m_lookup_table.set_cursor_pos(m_convList.pos); + update_lookup_table(m_lookup_table); } void WnnInstance::update_lookup_table_page_size (unsigned int page_size) @@ -798,5 +847,3 @@ - - diff --git a/scim-wnn/src/scim_wnn_imengine.h b/scim-wnn/src/scim_wnn_imengine.h index 5895fa7..4697160 100644 --- a/scim-wnn/src/scim_wnn_imengine.h +++ b/scim-wnn/src/scim_wnn_imengine.h @@ -90,6 +90,7 @@ PreEditor *m_preeditor; WnnConversion wnn; bool m_conversion; + bool m_yosoku; bool m_lookup; WnnConversionList m_convList; PropertyList m_proplist; @@ -104,6 +105,7 @@ protected: bool process_preedit_key_event(const KeyEvent &key); bool process_conversion_key_event(const KeyEvent &key); + bool process_yosoku_key_event(const KeyEvent &key); void startConversion(WideString s); void createLookupTable(WnnConversionList cList); void init(); @@ -136,6 +138,7 @@ // for Wnn7 k_conversion_ikeiji, // �۷����Ѵ� k_conversion_rensou, // Ϣ���Ѵ� + k_select_yosoku, // ͽ¬���� k_dummy;