diff --git a/honoka/libhonoka/convertor.cpp b/honoka/libhonoka/convertor.cpp index 8789efb..b9c1b4b 100644 --- a/honoka/libhonoka/convertor.cpp +++ b/honoka/libhonoka/convertor.cpp @@ -19,6 +19,22 @@ ***************************************************************************/ #include "convertor.h" +Segment::Segment(const WideString _kanji,const WideString _yomi) { + kanji = _kanji; + yomi = _yomi; +}; +Segment::~Segment() { +}; + +const WideString Segment::getKanji() { + return kanji; +}; + +const WideString Segment::getYomi() { + return yomi; +}; + + /* �������ߡ��᥽�åɤ������� */ Convertor::Convertor(ConfigPointer cfg) : HonokaPluginBase(String("Convertor")) @@ -130,3 +146,10 @@ // �����λ���ǡ���ˡ����ʤ�Τ���ꤷ�ޤ��礦�� return getName(); } + + +const vector Convertor::getSegmentList() +{ + // getText�ˤ�����Ρ� + return vector(); +} diff --git a/honoka/libhonoka/convertor.h b/honoka/libhonoka/convertor.h index b322fee..cd68d62 100644 --- a/honoka/libhonoka/convertor.h +++ b/honoka/libhonoka/convertor.h @@ -40,6 +40,17 @@ @author TAM (Teppei Tamra) */ +class Segment { +public: + Segment(const WideString _kanji,const WideString _yomi); + ~Segment(); + const WideString getKanji(); + const WideString getYomi(); +private: + WideString kanji; + WideString yomi; +}; + class Convertor : public HonokaPluginBase { public: Convertor(ConfigPointer cfg); @@ -62,6 +73,7 @@ virtual int getCaretPos(); virtual String getName(); virtual String getPropertyName(); + virtual const vector getSegmentList(); protected: ConfigPointer config; diff --git a/honoka/plugins/anthyconversion.cpp b/honoka/plugins/anthyconversion.cpp index 71e1869..2a3d155 100644 --- a/honoka/plugins/anthyconversion.cpp +++ b/honoka/plugins/anthyconversion.cpp @@ -88,6 +88,13 @@ return text; } +const vector AnthyConversion::getSegmentList() { + vector result; + for(unsigned int i = 0;i < convResult.size();i ++) result.push_back(Segment(convResult[i].kouho[convResult[i].pos].kanji,convResult[i].Yomi)); + return result; +}; + + int AnthyConversion::setPos(int p){ if ((p < convResult.size()) && (p >= 0)) pos = p; return pos; diff --git a/honoka/plugins/anthyconversion.h b/honoka/plugins/anthyconversion.h index bf6fc3d..fe80a2f 100644 --- a/honoka/plugins/anthyconversion.h +++ b/honoka/plugins/anthyconversion.h @@ -59,6 +59,7 @@ virtual int getCaretPos(); virtual String getName(); virtual String getPropertyName(); + virtual const vector getSegmentList(); protected: diff --git a/honoka/plugins/cannaconversion.cpp b/honoka/plugins/cannaconversion.cpp index b011a6d..71028e5 100644 --- a/honoka/plugins/cannaconversion.cpp +++ b/honoka/plugins/cannaconversion.cpp @@ -92,6 +92,12 @@ return text; } +const vector CannaConversion::getSegmentList() { + vector result; + for(unsigned int i = 0;i < convResult.size();i ++) result.push_back(Segment(convResult[i].kouho[convResult[i].pos].kanji,convResult[i].Yomi)); + return result; +} + int CannaConversion::setPos(int p){ if ((p < convResult.size()) && (p >= 0)) pos = p; RkGoTo(context,pos); diff --git a/honoka/plugins/cannaconversion.h b/honoka/plugins/cannaconversion.h index 274e296..650102c 100644 --- a/honoka/plugins/cannaconversion.h +++ b/honoka/plugins/cannaconversion.h @@ -60,6 +60,7 @@ virtual int getCaretPos(); virtual String getName(); virtual String getPropertyName(); + virtual const vector getSegmentList(); protected: void buildResult(); diff --git a/honoka/plugins/skkdicconversion.cpp b/honoka/plugins/skkdicconversion.cpp index 8568efe..9cf5231 100644 --- a/honoka/plugins/skkdicconversion.cpp +++ b/honoka/plugins/skkdicconversion.cpp @@ -88,6 +88,12 @@ return t; } +const vector SKKDicConversion::getSegmentList() { + vector result; + for(unsigned int i = 0;i < texts.size();i ++) result.push_back(Segment(texts[i],buns[i])); + return result; +} + int SKKDicConversion::setPos(int p){ if ((p >= 0) && (p < buns.size())) pos = p; return pos; diff --git a/honoka/plugins/skkdicconversion.h b/honoka/plugins/skkdicconversion.h index c45531c..8f39ff2 100644 --- a/honoka/plugins/skkdicconversion.h +++ b/honoka/plugins/skkdicconversion.h @@ -60,6 +60,7 @@ virtual int getCaretPos(); virtual String getName(); virtual String getPropertyName(); + virtual const vector getSegmentList(); protected: SKKDic *dic; diff --git a/honoka/plugins/wnnconversion.cpp b/honoka/plugins/wnnconversion.cpp index 9460288..0848ca8 100644 --- a/honoka/plugins/wnnconversion.cpp +++ b/honoka/plugins/wnnconversion.cpp @@ -307,6 +307,17 @@ return text; } +/*! + \fn WnnConversion::getSegmentList() + */ +const vector WnnConversion::getSegmentList() +{ + // getText�ˤ�����Ρ� + vector result; + for(unsigned int i = 0;i < bunsetu;i ++) result.push_back(Segment(bunList[i],yomiList[i])); + return result; +} + /*! \fn WnnConversion::getAttributeList() diff --git a/honoka/plugins/wnnconversion.h b/honoka/plugins/wnnconversion.h index afc1922..fcb8e40 100644 --- a/honoka/plugins/wnnconversion.h +++ b/honoka/plugins/wnnconversion.h @@ -71,6 +71,7 @@ virtual int getCaretPos(); virtual String getName(); virtual String getPropertyName(); + virtual const vector getSegmentList(); void updateYosoku(WideString text,const WideString yomi); diff --git a/honoka/src/honoka_imengine.cpp b/honoka/src/honoka_imengine.cpp index fc84ab7..fe88836 100644 --- a/honoka/src/honoka_imengine.cpp +++ b/honoka/src/honoka_imengine.cpp @@ -433,6 +433,58 @@ } + +/*! + \fn HonokaInstance::getConvertedText() + */ +const WideString HonokaInstance::getConvertedText() +{ + vector seglist = m_convertor->getSegmentList(); + segments = seglist; + WideString t; + for(unsigned int i = 0;i < segments.size();i ++) { + t += segments[i].getKanji(); + } + return t; +} + + +/*! + \fn HonokaInstance::getConvertedAttributeList() + */ +const AttributeList HonokaInstance::getConvertedAttributeList() +{ + AttributeList attr; + int c = 0; + for(unsigned int i = 0;i < segments.size();i ++) { + if (m_convertor->getPos() == i) { + Attribute a(c,segments[i].getKanji().length(),SCIM_ATTR_DECORATE,SCIM_ATTR_DECORATE_REVERSE); + attr.push_back(a); + break; + } else c += segments[i].getKanji().length(); + } + + return attr; +} + +/*! + \fn HonokaInstance::updateConvertedString() + */ +void HonokaInstance::updateConvertedString() +{ + WideString w = getConvertedText(); + AttributeList a = getConvertedAttributeList(); + int c = 0; + for(unsigned int i = 0;i < segments.size();i ++) { + if (m_convertor->getPos() == i) break; + else c += segments[i].getKanji().length(); + } + update_preedit_string(w,a); + update_preedit_caret(c); + +} + + /*! \fn HonokaInstance::changePreEditor(const String &name) */ @@ -605,8 +657,7 @@ void HonokaInstance::updateConversion() { // �Ѵ�����ɽ�������� - update_preedit_string(m_convertor->getText(),m_convertor->getAttributeList()); - update_preedit_caret(m_convertor->getCaretPos()); + updateConvertedString(); if (m_lookup) { m_lookup_table.set_cursor_pos(m_convList.pos); update_lookup_table(m_lookup_table); @@ -674,8 +725,8 @@ } else if (k_commit.comp(key)) { if (auto_conversion) { - commit_string(m_convertor->getText()); - if (prediction) if (m_predictor->isConnected()) m_predictor->update(m_convertor->getText(),m_preeditor->getText(true)); + commit_string(getConvertedText()); + if (prediction) if (m_predictor->isConnected()) m_predictor->update(getConvertedText(),m_preeditor->getText(true)); m_convertor->reset(); } else { commit_string(m_preeditor->getText(true)); @@ -780,7 +831,7 @@ // preeditor�ǽ����Ǥ��ʤ��ä����Ϥ�Ϥ�commit���ƥ��ץꥱ���������֤��٤����� if (m_preeditor->getTextLength()) { if (auto_conversion) { - commit_string(m_convertor->getText()); + commit_string(getConvertedText()); m_convertor->reset(); } else commit_string(m_preeditor->getText(true)); } @@ -829,12 +880,12 @@ } } else if (k_commit.comp(key)) { - commit_string(m_convertor->getText()); + commit_string(getConvertedText()); //while(preeditStack.size()) { // preeditStack.pop(); // } m_convertor->updateFrequency(); - if (prediction) if (m_predictor->isConnected()) m_predictor->update(m_convertor->getText(),m_preeditor->getText(true)); + if (prediction) if (m_predictor->isConnected()) m_predictor->update(getConvertedText(),m_preeditor->getText(true)); m_preeditor->reset(); m_convertor->reset(); m_conversion = false; @@ -848,8 +899,8 @@ if (k_result_to_preedit.comp(key)) { preeditStack.push(m_preeditor->getText()); m_preeditor->reset(); - m_preeditor->setText(m_convertor->getText()); - m_preeditor->setPos(m_convertor->getText().length()); + m_preeditor->setText(getConvertedText()); + m_preeditor->setPos(getConvertedText().length()); m_convertor->updateFrequency(); m_convertor->reset(); m_conversion = false; @@ -992,9 +1043,9 @@ } } */ - commit_string(m_convertor->getText()); + commit_string(getConvertedText()); m_convertor->updateFrequency(); - if (prediction) if (m_predictor->isConnected()) m_predictor->update(m_convertor->getText(),m_preeditor->getText(true)); + if (prediction) if (m_predictor->isConnected()) m_predictor->update(getConvertedText(),m_preeditor->getText(true)); m_preeditor->reset(); m_convertor->reset(); m_conversion = false; @@ -1114,8 +1165,7 @@ m_convList.pos = p; m_convertor->select(m_convList.pos); if (m_convList.kType != PREDICTION) { - update_preedit_string(m_convertor->getText(),m_convertor->getAttributeList()); - update_preedit_caret(m_convertor->getCaretPos()); + updateConvertedString(); } else { update_preedit_string(m_convList.kouho.at(m_convList.pos).kanji); update_preedit_caret(0); @@ -1145,8 +1195,7 @@ if (p < 0) p = 0; m_convList.pos = p; m_convertor->select(m_convList.pos); - update_preedit_string(m_convertor->getText(),m_convertor->getAttributeList()); - update_preedit_caret(m_convertor->getCaretPos()); + updateConvertedString(); m_lookup_table.set_cursor_pos(m_convList.pos); update_aux_string(m_convList.Title + getPosPerCount(m_convList.pos,m_convList.count())); show_aux_string(); @@ -1164,8 +1213,7 @@ if (p >= m_convList.count()) p = m_convList.count() - 1; m_convList.pos = p; m_convertor->select(m_convList.pos); - update_preedit_string(m_convertor->getText(),m_convertor->getAttributeList()); - update_preedit_caret(m_convertor->getCaretPos()); + updateConvertedString(); m_lookup_table.set_cursor_pos(m_convList.pos); update_aux_string(m_convList.Title + getPosPerCount(m_convList.pos,m_convList.count())); show_aux_string(); @@ -1195,9 +1243,9 @@ { // �ե��������򼺤ä��������ƥ��ߥåȡ��� if (m_conversion) { - commit_string(m_convertor->getText()); + commit_string(getConvertedText()); m_convertor->updateFrequency(); - if (prediction) if (m_predictor->isConnected()) m_predictor->update(m_convertor->getText(),m_preeditor->getText(true)); + if (prediction) if (m_predictor->isConnected()) m_predictor->update(getConvertedText(),m_preeditor->getText(true)); m_convertor->reset(); if (m_def_convertor != m_convertor) m_convertor = m_def_convertor; m_conversion = false; @@ -1290,8 +1338,7 @@ alp_count = 1; show_preedit_string(); - update_preedit_string(m_convertor->getText(),m_convertor->getAttributeList()); - update_preedit_caret(m_convertor->getCaretPos()); + updateConvertedString(); if (alp == -1) { startLookup(); } @@ -1328,8 +1375,8 @@ } show_preedit_string(); - update_preedit_string(m_convertor->getText()); - update_preedit_caret(m_convertor->getText().size()); + update_preedit_string(getConvertedText()); + update_preedit_caret(getConvertedText().size()); } diff --git a/honoka/src/honoka_imengine.h b/honoka/src/honoka_imengine.h index 7cfed09..19ac726 100644 --- a/honoka/src/honoka_imengine.h +++ b/honoka/src/honoka_imengine.h @@ -137,7 +137,7 @@ WideString yomi; stack preeditStack; Convertor *m_multi; - vector split(const String &str,const char &sep = ','); + vector segments; protected: bool process_preedit_key_event(const KeyEvent &key); bool process_conversion_key_event(const KeyEvent &key); @@ -154,6 +154,10 @@ void autoConversion(); bool pluginCheck(HonokaPluginBase *p); WideString getPosPerCount(int p,int c); + vector split(const String &str,const char &sep = ','); + const WideString getConvertedText(); + const AttributeList getConvertedAttributeList(); + void updateConvertedString(); private: HonokaKeyEventList k_conversion_start, // �Ѵ����� diff --git a/honoka/src/multiconvertor.cpp b/honoka/src/multiconvertor.cpp index f8f6b11..b3a5d3a 100644 --- a/honoka/src/multiconvertor.cpp +++ b/honoka/src/multiconvertor.cpp @@ -74,10 +74,12 @@ def = instance->m_def_convertor; texts.clear(); + yomi.clear(); int b = instance->m_def_convertor->ren_conversion(); for(unsigned int i = 0;i < b;i ++) { ResultList l = instance->m_def_convertor->getResultList(i); texts.push_back(l.kouho[0].kanji); + yomi.push_back(l.Yomi); } for(unsigned int i = 0;i < instance->convertors.size();i ++) { if (nuc.find(instance->convertors[i]) != nuc.end()) continue; @@ -102,6 +104,12 @@ return t; } +const vector MultiConvertor::getSegmentList() { + vector result; + for(unsigned int i = 0;i < texts.size();i ++) result.push_back(Segment(texts[i],yomi[i])); + return result; +}; + int MultiConvertor::setPos(int p){ int cp = instance->m_def_convertor->setPos(p); for(unsigned int i = 0;i < instance->convertors.size();i ++) { @@ -217,6 +225,7 @@ // �ʲ������档 if (!instance->m_def_convertor->resizeRegion(w)) return false; texts.clear(); + yomi.clear(); int p = getPos(); vector s; for(unsigned int i = 0;;i ++) { @@ -224,6 +233,7 @@ if (!l.count()) break; s.push_back(l.Yomi.length()); texts.push_back(l.kouho[0].kanji); + yomi.push_back(l.Yomi); } instance->m_def_convertor->setPos(p); for(unsigned int i = 0;i < instance->convertors.size();i ++) { diff --git a/honoka/src/multiconvertor.h b/honoka/src/multiconvertor.h index 4c85036..fa8a5f5 100644 --- a/honoka/src/multiconvertor.h +++ b/honoka/src/multiconvertor.h @@ -61,12 +61,14 @@ virtual int getCaretPos(); virtual String getName(); virtual String getPropertyName(); + virtual const vector getSegmentList(); protected: HonokaInstance *instance; vector results; ResultList result; vector texts; + vector yomi; Convertor *def; set nuc; };