diff --git a/scim-wnn/src/scim_wnn_imengine.cpp b/scim-wnn/src/scim_wnn_imengine.cpp index 1166207..bb6c503 100644 --- a/scim-wnn/src/scim_wnn_imengine.cpp +++ b/scim-wnn/src/scim_wnn_imengine.cpp @@ -62,6 +62,8 @@ #define SCIM_CONFIG_WNN_SERVER "/IMEngine/Wnn/Server" #define SCIM_CONFIG_WNN_RC "/IMEngine/Wnn/Rc" #define SCIM_CONFIG_WNN_KEY "/IMEngine/Wnn/Key/" +#define SCIM_CONFIG_WNN_ALP "/IMEngine/Wnn/AutoLookupPopup" +#define SCIM_PROP_WNN_INPUTMODE "/IMEngine/Wnn/InputMode" static Pointer _scim_wnn_factory; static ConfigPointer _scim_config; @@ -194,9 +196,12 @@ : IMEngineInstanceBase (factory, encoding, id) { m_conversion = false; + m_lookup = false; String host,rc; host = _scim_config->read(String(SCIM_CONFIG_WNN_SERVER),String("localhost")); rc = _scim_config->read(String(SCIM_CONFIG_WNN_RC),String("/usr/lib/wnn7/ja_JP/wnnenvrc")); + alp = _scim_config->read(String(SCIM_CONFIG_WNN_ALP),1); + wnn.wnnConnect(String("test"),host,rc,10); // �ǥե���ȥ������ꡣ @@ -240,6 +245,9 @@ scim_string_to_key_list(k_backward, _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("Backward"), String("Left"))); + scim_string_to_key_list(k_lookup_popup, + _scim_config->read(String(SCIM_CONFIG_WNN_KEY) + String("LookupPopup"), + String("Alt+s"))); } @@ -268,7 +276,7 @@ startConversion(m_rk.getText(true)); show_preedit_string(); update_preedit_string(wnn.getText(),wnn.getAttributeList()); - update_preedit_caret(wnn.getText().length()); + update_preedit_caret(wnn.getCaretPos()); return(true); } else if (k_commit.comp(key)) { @@ -329,6 +337,15 @@ */ bool WnnInstance::process_conversion_key_event(const KeyEvent &key) { + if ((alp < alp_count) && (alp != 0)) { + if (!m_lookup) startLookup(); + } + + if (k_lookup_popup.comp(key)) { + if (m_lookup) return(true); + startLookup(); + return(true); + } else if (k_commit.comp(key)) { commit_string(wnn.getText()); wnn.updateFrequency(); @@ -336,6 +353,9 @@ wnn.reset(); m_conversion = false; hide_preedit_string(); + hide_lookup_table(); + m_lookup = false; + alp_count = 0; return(true); } else if (k_cancel.comp(key) || k_backspace.comp(key)) { @@ -343,6 +363,9 @@ m_conversion = false; update_preedit_string(m_rk.getText()); update_preedit_caret(m_rk.getPos()); + hide_lookup_table(); + m_lookup = false; + alp_count = 0; return(true); } else if (k_conversion_next.comp(key) || k_conversion_prev.comp(key)) { @@ -352,7 +375,12 @@ wnn.select(m_convList.pos); update_preedit_string(wnn.getText(),wnn.getAttributeList()); - update_preedit_caret(wnn.getText().length()); + update_preedit_caret(wnn.getCaretPos()); + if (m_lookup) { + m_lookup_table.set_cursor_pos(m_convList.pos); + update_lookup_table(m_lookup_table); + } + alp_count ++; return(true); } else if (k_conversion_expand.comp(key) || k_conversion_shrink.comp(key)) { @@ -361,14 +389,20 @@ if (!r) return(true); m_convList = wnn.getConversionList(); update_preedit_string(wnn.getText(),wnn.getAttributeList()); - update_preedit_caret(wnn.getText().length()); + update_preedit_caret(wnn.getCaretPos()); + hide_lookup_table(); + m_lookup = false; + alp_count = 0; return(true); } else if (k_conversion_forward.comp(key) || k_conversion_backward.comp(key)) { k_conversion_backward.comp(key) ? wnn.setPos(wnn.getPos() - 1) : wnn.setPos(wnn.getPos() + 1); m_convList = wnn.getConversionList(); update_preedit_string(wnn.getText(),wnn.getAttributeList()); - update_preedit_caret(wnn.getText().length()); + update_preedit_caret(wnn.getCaretPos()); + hide_lookup_table(); + m_lookup = false; + alp_count = 0; return(true); } else if (isprint(key.code)) { @@ -378,6 +412,9 @@ wnn.reset(); m_conversion = false; hide_preedit_string(); + hide_lookup_table(); + m_lookup = false; + alp_count = 0; return(process_preedit_key_event(key)); } @@ -394,15 +431,15 @@ void WnnInstance::select_candidate (unsigned int item) { - if (!m_lookup_table.number_of_candidates ()) return; + if (!m_lookup_table.number_of_candidates()) return; - unsigned int current = m_lookup_table.get_cursor_pos_in_current_page (); - - if (current != item) { - m_lookup_table.set_cursor_pos_in_current_page (item); - update_lookup_table (m_lookup_table); - } - + int p = m_lookup_table.get_current_page_start() + item; + m_convList.pos = p; + wnn.select(m_convList.pos); + 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); } void WnnInstance::update_lookup_table_page_size (unsigned int page_size) @@ -472,4 +509,31 @@ wnn.setYomiText(s); wnn.ren_conversion(); m_convList = wnn.getConversionList(); + alp_count = 0; +} + + +/*! + \fn WnnInstance::createLookupTable(WnnConversionList cList) + */ +void WnnInstance::createLookupTable(WnnConversionList cList) +{ + m_lookup_table.clear(); + if (!cList.count) return; + for (unsigned int i = 0;i < cList.count;i ++) { + m_lookup_table.append_candidate(cList.kouho.at(i)); + } + m_lookup_table.set_cursor_pos(cList.pos); + update_lookup_table(m_lookup_table); +} + + +/*! + \fn WnnInstance::startLookup() + */ +void WnnInstance::startLookup() +{ + createLookupTable(m_convList); + m_lookup = true; + show_lookup_table(); } diff --git a/scim-wnn/src/scim_wnn_imengine.h b/scim-wnn/src/scim_wnn_imengine.h index 44ac21b..b4ae72a 100644 --- a/scim-wnn/src/scim_wnn_imengine.h +++ b/scim-wnn/src/scim_wnn_imengine.h @@ -76,17 +76,23 @@ virtual void focus_in (); virtual void focus_out (); virtual void trigger_property (const String &property); + void startLookup(); protected: CommonLookupTable m_lookup_table; Romkan m_rk; WnnConversion wnn; bool m_conversion; + bool m_lookup; WnnConversionList m_convList; + PropertyList m_proplist; + int alp; + int alp_count; protected: bool process_preedit_key_event(const KeyEvent &key); bool process_conversion_key_event(const KeyEvent &key); void startConversion(WideString s); + void createLookupTable(WnnConversionList cList); private: WnnKeyEventList @@ -103,6 +109,7 @@ k_conversion_backward, // ��ʸ�� k_forward, // ���������ư/�� k_backward, // ���������ư/��� + k_lookup_popup, // �������ɽ�� k_dummy; }; diff --git a/scim-wnn/src/wnnconversion.cpp b/scim-wnn/src/wnnconversion.cpp index f925831..d2e30ce 100644 --- a/scim-wnn/src/wnnconversion.cpp +++ b/scim-wnn/src/wnnconversion.cpp @@ -230,11 +230,11 @@ caretPos = 0; for(unsigned int i = 0;i < bunsetu;i ++) { if (pos == i) { + caretPos = w.length(); attr.clear(); Attribute a(w.length(),bunList[i].length(),SCIM_ATTR_DECORATE,SCIM_ATTR_DECORATE_REVERSE); attr.push_back(a); } - if (pos < i) caretPos += bunList[i].length(); w = w + bunList[i]; } text = w;