diff --git a/honoka/src/honoka_def.h b/honoka/src/honoka_def.h index 66f7ffa..c8d1207 100644 --- a/honoka/src/honoka_def.h +++ b/honoka/src/honoka_def.h @@ -128,6 +128,7 @@ #define HONOKA_PROP_CONVERSIONMODE "/IMEngine/Honoka/ConversionMode" #define HONOKA_PROP_CONVERTOR "/IMEngine/Honoka/Convertor" #define HONOKA_PROP_PREDICTOR "/IMEngine/Honoka/Predictor" +#define HONOKA_PROP_SPLITTER "/IMEngine/Honoka/Splitter" #define HONOKA_PREVIOUS_PREEDITOR "/IMEngine/Honoka/PreviousSetting/PreEditor" #define HONOKA_PREVIOUS_PREDICTOR "/IMEngine/Honoka/PreviousSetting/Predictor" diff --git a/honoka/src/honoka_imengine.cpp b/honoka/src/honoka_imengine.cpp index a651385..80ef725 100644 --- a/honoka/src/honoka_imengine.cpp +++ b/honoka/src/honoka_imengine.cpp @@ -483,6 +483,9 @@ changePredictor(_scim_config->read(String(HONOKA_PREVIOUS_PREDICTOR),String())); changeConvertor(_scim_config->read(String(HONOKA_PREVIOUS_CONVERTOR),String())); } + + m_splitter = 0; + //if (1) changeSplitter(String("AUTO")); } @@ -588,6 +591,26 @@ } +/*! + \fn HonokaInstance::changeSplitter(const String &name) + */ +bool HonokaInstance::changeSplitter(const String &name) +{ + // Splitterを変更するメソッド。 + if (name == "AUTO") { + m_splitter = 0; + return true; + } + for(unsigned int i = 0;i < convertors.size();i ++) { + if (convertors[i]->getName() == name) { + m_splitter = convertors[i]; + return true; + } + } + return false; +} + + /*! \fn HonokaInstance::changePredictor(const String &name) @@ -632,6 +655,18 @@ m_proplist.push_back(p); } } + if (1) { + p = Property(HONOKA_PROP_SPLITTER,"",String(""),_("splitter")); + m_proplist.push_back(p); + p = Property(String(HONOKA_PROP_SPLITTER) + String("/AUTO"), + _("Auto"),String(""),_("mode status")); + m_proplist.push_back(p); + for(unsigned int i = 0;i < convertors.size();i ++) { + p = Property(String(HONOKA_PROP_SPLITTER) + String("/") + convertors[i]->getName(), + convertors[i]->getPropertyName(),String(""),_("mode status")); + m_proplist.push_back(p); + } + } p = Property(HONOKA_PROP_CONVERTOR,"",String(""),_("convertor")); m_proplist.push_back(p); for(unsigned int i = 0;i < convertors.size();i ++) { @@ -657,6 +692,13 @@ } update_property(*it); } + if (1) { + it = find(m_proplist.begin(),m_proplist.end(),HONOKA_PROP_SPLITTER); + if (it != m_proplist.end()) { + if (m_splitter == 0) it->set_label(_("Auto") + String(" ")); + else it->set_label(m_splitter->getPropertyName() + String(" ")); + } + } it = find(m_proplist.begin(),m_proplist.end(),HONOKA_PROP_CONVERTOR); if (it != m_proplist.end()) { it->set_label(m_convertor->getPropertyName() + String(" ")); @@ -1601,6 +1643,13 @@ } updateProperty(); } + + s = HONOKA_PROP_SPLITTER; + if ((property.length() > s.length()) && (property.substr(0,s.length()) == s)) { + changeSplitter(property.substr(s.length() + 1)); + updateProperty(); + } + s = HONOKA_PROP_CONVERSIONMODE; if (property == s) { auto_conversion ? auto_conversion = false : auto_conversion = true; @@ -1624,11 +1673,36 @@ if (multi) m_convertor = m_multi; if (!s.length()) s = yomi; else yomi = s; + vector spsegs; m_lookup = false; m_lookup_table.clear(); hide_lookup_table(); hide_aux_string(); + + if (m_splitter && (m_splitter != m_convertor) && (!multi)) { + m_splitter->selected(); + if (!m_splitter->isConnected()) { + if (!m_splitter->connect()) { + m_splitter->unSelected(); + update_aux_string(utf8_mbstowcs(String(_("could not connect to server.")))); + show_aux_string(); + return; + } + } + m_splitter->setYomiText(s); + if (m_splitter->ren_conversion() <= 0) { + update_aux_string(utf8_mbstowcs(String(_("The error was received from Converter. ")))); + show_aux_string(); + return; + } + spsegs = m_splitter->getSegmentList(); + m_splitter->reset(); + m_splitter->unSelected(); + s.clear(); + for(unsigned int i = 0;i < spsegs.size();i ++) s += spsegs[i].getYomi(); + } + if (!m_convertor->isConnected()) { if (!m_convertor->connect()) { update_aux_string(utf8_mbstowcs(String(_("could not connect to server.")))); @@ -1645,6 +1719,16 @@ m_convertor = m_def_convertor; return; } + + if (m_splitter && (m_splitter != m_convertor) && (!multi)) { + // aline + for(unsigned int i = 0;i < spsegs.size();i ++) { + int bl = spsegs[i].getYomi().length(); + int cl = m_convertor->getResultList(i).Yomi.length(); + if (bl != cl) m_convertor->resizeRegion(bl - cl); + } + } + m_no_update = false; m_convList.kouho.clear(); m_convList = m_convertor->getResultList(); diff --git a/honoka/src/honoka_imengine.h b/honoka/src/honoka_imengine.h index e503d76..7ec3c53 100644 --- a/honoka/src/honoka_imengine.h +++ b/honoka/src/honoka_imengine.h @@ -121,6 +121,7 @@ Convertor *m_convertor; Convertor *m_def_convertor; Predictor *m_predictor; + Convertor *m_splitter; //bool m_conversion; //bool m_prediction; //bool m_lookup; @@ -171,6 +172,7 @@ bool changePreEditor(const String &name); bool changeConvertor(const String &name); bool changePredictor(const String &name); + bool changeSplitter(const String &name); void autoConversion(); bool pluginCheck(HonokaPluginBase *p); WideString getPosPerCount(int p,int c);