void CIMIClassicView::updateWindows(unsigned mask) { if (!m_pWinHandler) return; if (mask & PREEDIT_MASK) { CPreEditString ps; getPreeditString (ps); m_pWinHandler->updatePreedit (&ps); } if ((mask & PREEDIT_MASK) || (mask & CANDIDATE_MASK)) { unsigned word_num = m_pIC->getBestSentence (m_tailSentence, m_candiFrIdx); if (word_num <= 1 || (!m_candiList.empty() && m_tailSentence == m_candiList[0].m_cwstr)) m_tailSentence.clear (); } if (mask & CANDIDATE_MASK) { CCandidateList cl; getCandidateList (cl, m_candiPageFirst, m_candiWindowSize); m_pWinHandler->updateCandidates (&cl); } }
void CIMIClassicView::updateWindows(unsigned mask) { if (!m_pWinHandler) return; if (mask & PREEDIT_MASK) { m_uiPreeditString.clear(); getPreeditString(m_uiPreeditString); // m_pWinHandler->updatePreedit(&ps); handlerUpdatePreedit(&m_uiPreeditString); } if ((mask & PREEDIT_MASK) || (mask & CANDIDATE_MASK)) { // calculate all possible best sentences m_sentences.clear(); int best_rank = -1; for (size_t i = 0; i < m_pIC->getNBest(); i++) { wstring sentence; unsigned word_num = m_pIC->getBestSentence(sentence, i, m_candiFrIdx); if (word_num == 0) goto pass; // when sentence is not worthy of #ifdef DEBUG printf("%d ", i); print_wide(sentence.c_str()); printf("\n"); #endif for (size_t j = 0; j < m_sentences.size(); j++) { if (sentence == m_sentences[j].second) goto pass; } if (best_rank < 0 && word_num > 1) { best_rank = i; } m_sentences.push_back(std::make_pair(i, sentence)); pass: continue; } // build all possible tails with best_rank std::vector<CCandidates> tails = m_pIC->getBestSentenceTails(best_rank, m_candiFrIdx); m_tails.clear(); for (size_t i = 0; i < tails.size(); i++) { CCandidates& tail = tails[i]; wstring tail_text; // translate this tail into text for (size_t j = 0; j < tail.size(); j++) { tail_text += tail[j].m_cwstr; } m_tails.push_back(std::make_pair(tail_text, tail)); } } if (mask & CANDIDATE_MASK) { m_uiCandidateList.clear(); getCandidateList(m_uiCandidateList, m_candiPageFirst, m_candiWindowSize); // m_pWinHandler->updateCandidates(&cl); handlerUpdateCandidates(&m_uiPreeditString, &m_uiCandidateList); } }