diff --git a/honoka/src/anthyconversion.cpp b/honoka/src/anthyconversion.cpp index 3651530..4c6f0b5 100644 --- a/honoka/src/anthyconversion.cpp +++ b/honoka/src/anthyconversion.cpp @@ -167,5 +167,10 @@ return(String("Anthy")); } +String AnthyConversion::getPropertyName() +{ + return(String("Anthy")); +} + #endif diff --git a/honoka/src/anthyconversion.h b/honoka/src/anthyconversion.h index 5cdc83d..9660501 100644 --- a/honoka/src/anthyconversion.h +++ b/honoka/src/anthyconversion.h @@ -65,6 +65,8 @@ virtual void disconnect(); virtual int getCaretPos(); virtual String getName(); + virtual String getPropertyName(); + protected: void buildResult(); diff --git a/honoka/src/convertor.cpp b/honoka/src/convertor.cpp index ccc4d1b..965d0b9 100644 --- a/honoka/src/convertor.cpp +++ b/honoka/src/convertor.cpp @@ -99,3 +99,8 @@ { return(String("Convertor")); } + +String Convertor::getPropertyName() +{ + return(getName()); +} diff --git a/honoka/src/convertor.h b/honoka/src/convertor.h index bc23d47..48af48c 100644 --- a/honoka/src/convertor.h +++ b/honoka/src/convertor.h @@ -66,6 +66,7 @@ virtual void disconnect(); virtual int getCaretPos(); virtual String getName(); + virtual String getPropertyName(); protected: ConfigPointer config; diff --git a/honoka/src/honoka_def.h b/honoka/src/honoka_def.h index 7aee6a9..dff816f 100644 --- a/honoka/src/honoka_def.h +++ b/honoka/src/honoka_def.h @@ -65,6 +65,10 @@ #define HONOKA_DEFAULT_KEY_CONVERT_HALF "F6" #define HONOKA_CONFIG_KEY_CONVERT_WIDE "/IMEngine/Honoka/Key/ConvertWide" #define HONOKA_DEFAULT_KEY_CONVERT_WIDE "F5" +#define HONOKA_CONFIG_KEY_NEXT_CONVERTOR "/IMEngine/Honoka/Key/NextConvertor" +#define HONOKA_DEFAULT_KEY_NEXT_CONVERTOR "Control+Page_Down" +#define HONOKA_CONFIG_KEY_PREV_CONVERTOR "/IMEngine/Honoka/Key/PrevConvertor" +#define HONOKA_DEFAULT_KEY_PREV_CONVERTOR "Control+Page_Up" #define HONOKA_CONFIG_KEY_CONVERSION_IKEIJI "/IMEngine/Honoka/Key/ConversionIkeiji" #define HONOKA_DEFAULT_KEY_CONVERSION_IKEIJI "Shift+F8" @@ -104,9 +108,10 @@ #define HONOKA_DEFAULT_YOSOKU false #endif -#define SCIM_PROP_WNN_MODESTATUS "/IMEngine/Honoka/Property/ModeStatus" -#define SCIM_PROP_WNN_INPUTMODE "/IMEngine/Honoka/InputMode" -#define SCIM_PROP_WNN_CONVERSIONMODE "/IMEngine/Honoka/ConversionMode" +#define HONOKA_PROP_MODESTATUS "/IMEngine/Honoka/Property/ModeStatus" +#define HONOKA_PROP_INPUTMODE "/IMEngine/Honoka/InputMode" +#define HONOKA_PROP_CONVERSIONMODE "/IMEngine/Honoka/ConversionMode" +#define HONOKA_PROP_CONVERTOR "/IMEngine/Honoka/Convertor" // Romkan diff --git a/honoka/src/honoka_imengine.cpp b/honoka/src/honoka_imengine.cpp index b8baa35..c381652 100644 --- a/honoka/src/honoka_imengine.cpp +++ b/honoka/src/honoka_imengine.cpp @@ -183,7 +183,14 @@ preeditors.push_back(new Romkan(_scim_config)); preeditors.push_back(new KanaInput(_scim_config)); m_preeditor = preeditors.at(0); - m_convertor = 0; + + convertors.push_back(new WnnConversion(_scim_config)); + #ifdef HAVE_LIBANTHY + convertors.push_back(new AnthyConversion(_scim_config)); + #endif + m_convertor = convertors.at(0); + + init(); } @@ -213,14 +220,6 @@ yosoku = _scim_config->read(String(HONOKA_CONFIG_YOSOKU),HONOKA_DEFAULT_YOSOKU); sType = _scim_config->read(String(HONOKA_CONFIG_SERVERTYPE),String(HONOKA_DEFAULT_SERVERTYPE)); - if (m_convertor) delete(m_convertor); - #ifdef HAVE_LIBANTHY - if (sType == "Anthy") - m_convertor = new AnthyConversion(_scim_config); - else - #endif - m_convertor = new WnnConversion(_scim_config); - defaultPreEditor = _scim_config->read(String(HONOKA_CONFIG_DEFAULT_PREEDITOR),String(HONOKA_DEFAULT_DEFAULT_PREEDITOR)); auto_conversion = _scim_config->read(String(HONOKA_CONFIG_AUTO_CONVERSION),HONOKA_DEFAULT_AUTO_CONVERSION);; @@ -305,6 +304,12 @@ scim_string_to_key_list(k_auto_conversion, _scim_config->read(String(HONOKA_CONFIG_KEY_AUTO_CONVERSION), String(HONOKA_DEFAULT_KEY_AUTO_CONVERSION))); + scim_string_to_key_list(k_next_convertor, + _scim_config->read(String(HONOKA_CONFIG_KEY_NEXT_CONVERTOR), + String(HONOKA_DEFAULT_KEY_NEXT_CONVERTOR))); + scim_string_to_key_list(k_prev_convertor, + _scim_config->read(String(HONOKA_CONFIG_KEY_PREV_CONVERTOR), + String(HONOKA_DEFAULT_KEY_PREV_CONVERTOR))); changePreEditor(defaultPreEditor); @@ -329,6 +334,22 @@ } + +/*! + \fn HonokaInstance::changeConvertor(const String &name) + */ +void HonokaInstance::changeConvertor(const String &name) +{ + for(unsigned int i = 0;i < convertors.size();i ++) { + if (convertors[i]->getPropertyName() == name) { + m_convertor = convertors[i]; + return; + } + } + return; +} + + /*! \fn HonokaInstance::updateProperty() */ @@ -336,32 +357,44 @@ { if (m_proplist.empty()) { Property p; - p = Property(SCIM_PROP_WNN_INPUTMODE,"",String(""),_("input mode")); + p = Property(HONOKA_PROP_INPUTMODE,"",String(""),_("input mode")); m_proplist.push_back(p); for(unsigned int i = 0;i < preeditors.size();i ++) { - p = Property(String(SCIM_PROP_WNN_INPUTMODE) + String("/") + preeditors[i]->getPropertyName(), + p = Property(String(HONOKA_PROP_INPUTMODE) + String("/") + preeditors[i]->getPropertyName(), preeditors[i]->getName(),String(""),_("mode status")); m_proplist.push_back(p); } - p = Property(SCIM_PROP_WNN_MODESTATUS,"",String(""),_("mode status")); + p = Property(HONOKA_PROP_CONVERTOR,"",String(""),_("convertor")); m_proplist.push_back(p); - p = Property(SCIM_PROP_WNN_CONVERSIONMODE,"",String(""),_("conversion mode")); + for(unsigned int i = 0;i < convertors.size();i ++) { + p = Property(String(HONOKA_PROP_CONVERTOR) + String("/") + convertors[i]->getPropertyName(), + convertors[i]->getName(),String(""),_("mode status")); + m_proplist.push_back(p); + } + p = Property(HONOKA_PROP_MODESTATUS,"",String(""),_("mode status")); + m_proplist.push_back(p); + p = Property(HONOKA_PROP_CONVERSIONMODE,"",String(""),_("conversion mode")); m_proplist.push_back(p); } PropertyList::iterator it; - it = find(m_proplist.begin(),m_proplist.end(),SCIM_PROP_WNN_INPUTMODE); + it = find(m_proplist.begin(),m_proplist.end(),HONOKA_PROP_INPUTMODE); if (it != m_proplist.end()) { it->set_label(m_preeditor->getName()); } update_property(*it); - it = find(m_proplist.begin(),m_proplist.end(),SCIM_PROP_WNN_MODESTATUS); + it = find(m_proplist.begin(),m_proplist.end(),HONOKA_PROP_CONVERTOR); + if (it != m_proplist.end()) { + it->set_label(m_convertor->getName()); + } + update_property(*it); + it = find(m_proplist.begin(),m_proplist.end(),HONOKA_PROP_MODESTATUS); if (it != m_proplist.end()) { if (m_conversion) it->set_label(_("Kanji")); else if (m_yosoku) it->set_label(_("Yosoku")); else it->set_label(m_preeditor->getModeName()); } update_property(*it); - it = find(m_proplist.begin(),m_proplist.end(),SCIM_PROP_WNN_CONVERSIONMODE); + it = find(m_proplist.begin(),m_proplist.end(),HONOKA_PROP_CONVERSIONMODE); if (it != m_proplist.end()) { if (auto_conversion) it->set_label(_("AUTO")); else it->set_label(_("REN")); @@ -384,7 +417,8 @@ update_preedit_string(m_preeditor->getText(),m_preeditor->getAttributeList()); update_preedit_caret(m_preeditor->getPos()); } - if ((!m_conversion) && yosoku && m_convertor->isConnected() && (sType == "Wnn7") && (!auto_conversion)) { + if ((!m_conversion) && yosoku && m_convertor->isConnected() && (sType == "Wnn7") && + (!auto_conversion) && (m_convertor->getName() == "Wnn")) { m_convList = m_convertor->getYosokuList(m_preeditor->getText()); if (m_convList.count) { m_lookup_table.clear(); @@ -524,6 +558,23 @@ return(true); } + if (k_next_convertor.comp(key) || k_prev_convertor.comp(key)) { + for(unsigned int i = 0;i < convertors.size();i ++) { + if (convertors[i]->getPropertyName() == m_convertor->getPropertyName()) { + if (k_next_convertor.comp(key)) { + if (i == (convertors.size() - 1)) i = 0; + else i ++; + } else { + if (i == 0) i = convertors.size() - 1; + else i --; + } + changeConvertor(convertors[i]->getPropertyName()); + updatePreEditor(); + return(true); + } + } + } + if (k_auto_conversion.comp(key)) { auto_conversion ? auto_conversion = false : auto_conversion = true; updatePreEditor(); @@ -875,12 +926,17 @@ void HonokaInstance::trigger_property (const String &property) { - String s = SCIM_PROP_WNN_INPUTMODE; + String s = HONOKA_PROP_INPUTMODE; if ((property.length() > s.length()) && (property.substr(0,s.length()) == s)) { changePreEditor(property.substr(s.length() + 1)); updateProperty(); } - s = SCIM_PROP_WNN_CONVERSIONMODE; + s = HONOKA_PROP_CONVERTOR; + if ((property.length() > s.length()) && (property.substr(0,s.length()) == s)) { + changeConvertor(property.substr(s.length() + 1)); + updateProperty(); + } + s = HONOKA_PROP_CONVERSIONMODE; if (property == s) { auto_conversion ? auto_conversion = false : auto_conversion = true; updatePreEditor(); diff --git a/honoka/src/honoka_imengine.h b/honoka/src/honoka_imengine.h index 8c740be..10a78bb 100644 --- a/honoka/src/honoka_imengine.h +++ b/honoka/src/honoka_imengine.h @@ -117,6 +117,7 @@ void updateProperty(); void updateConversion(); void changePreEditor(const String &name); + void changeConvertor(const String &name); void autoConversion(); private: @@ -144,6 +145,8 @@ k_convert_half, // Ⱦ���Ѵ� k_convert_wide, // �����Ѵ� k_auto_conversion, // �Ѵ��⡼�ɥȥ��� + k_next_convertor, // �����Ѵ����󥸥�� + k_prev_convertor, // �����Ѵ����󥸥�� // for Wnn7 k_conversion_ikeiji, // �۷����Ѵ� diff --git a/honoka/src/wnnconversion.cpp b/honoka/src/wnnconversion.cpp index 21632a6..48d40a7 100644 --- a/honoka/src/wnnconversion.cpp +++ b/honoka/src/wnnconversion.cpp @@ -497,4 +497,10 @@ return(String("Wnn")); } +String WnnConversion::getPropertyName() +{ + return(String("Wnn")); +} + + diff --git a/honoka/src/wnnconversion.h b/honoka/src/wnnconversion.h index cd12211..39114b2 100644 --- a/honoka/src/wnnconversion.h +++ b/honoka/src/wnnconversion.h @@ -74,6 +74,7 @@ virtual void disconnect(); virtual int getCaretPos(); virtual String getName(); + virtual String getPropertyName(); protected: