diff --git a/honoka/src/acpredictor.cpp b/honoka/src/acpredictor.cpp index d410370..47f2b0d 100644 --- a/honoka/src/acpredictor.cpp +++ b/honoka/src/acpredictor.cpp @@ -42,6 +42,7 @@ : Predictor(cfg) { instance = i; + multi_mode = true; } @@ -62,13 +63,33 @@ instance->m_convertor->setYomiText(str); if (instance->m_convertor->ren_conversion() != -1) { vector segments = instance->m_convertor->getSegmentList(); - WideString t; + WideString t,l; for(unsigned int i = 0;i < segments.size();i ++) t += segments[i].getKanji(); + if (multi_mode) l = t + utf8_mbstowcs(String(" (") + instance->m_convertor->getPropertyName() + String(")")); result.kType = PREDICTION; - result.kouho.push_back(ResultEntry(t)); + result.kouho.push_back(ResultEntry(t,l)); } instance->m_convertor->reset(); } + if (multi_mode) { + for(unsigned int i = 0;i < instance->convertors.size();i ++) { + if (instance->convertors[i] != instance->m_convertor) { + if (instance->convertors[i]->isConnected()) { + instance->convertors[i]->setYomiText(str); + if (instance->convertors[i]->ren_conversion() != -1) { + vector segments = instance->convertors[i]->getSegmentList(); + WideString t,l; + for(unsigned int j = 0;j < segments.size();j ++) t += segments[j].getKanji(); + l = t + utf8_mbstowcs(String(" (") + instance->convertors[i]->getPropertyName() + String(")")); + result.kType = PREDICTION; + result.kouho.push_back(ResultEntry(t,l)); + } + instance->convertors[i]->reset(); + } + } + } + } + return result; } @@ -78,7 +99,14 @@ */ void ACPredictor::disconnect() { - if (instance->m_convertor->isConnected()) return instance->m_convertor->disconnect(); + if (multi_mode) { + for(unsigned int i = 0;i < instance->convertors.size();i ++) { + if ((instance->convertors[i]->isConnected()) && (instance->m_convertor != instance->convertors[i])) { + instance->convertors[i]->disconnect(); + } + } + } + if (instance->m_convertor->isConnected()) instance->m_convertor->disconnect(); return; } @@ -88,6 +116,13 @@ */ bool ACPredictor::connect() { + if (multi_mode) { + for(unsigned int i = 0;i < instance->convertors.size();i ++) { + if ((!instance->convertors[i]->isConnected()) && (instance->m_convertor != instance->convertors[i])) { + instance->convertors[i]->connect(); + } + } + } if (!instance->m_convertor->isConnected()) return instance->m_convertor->connect(); return true; } diff --git a/honoka/src/acpredictor.h b/honoka/src/acpredictor.h index 0f252a0..ac591fe 100644 --- a/honoka/src/acpredictor.h +++ b/honoka/src/acpredictor.h @@ -44,6 +44,7 @@ virtual void update(const WideString str,const WideString yomi); protected: HonokaInstance *instance; + bool multi_mode; };