MCPcopy Create free account
hub / github.com/EasyIME/PIME / updateCandidateList

Method updateCandidateList

PIMETextService/PIMEClient.cpp:344–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342}
343
344void Client::updateCandidateList(Json::Value& msg, Ime::EditSession* session) {
345 // handle candidate list
346 const auto& showCandidatesVal = msg["showCandidates"];
347 if (showCandidatesVal.isBool()) {
348 if (showCandidatesVal.asBool()) {
349 // start composition if we are not composing.
350 // this is required to get correctly position the candidate window
351 if (!textService_->isComposing()) {
352 textService_->startComposition(session->context());
353 }
354 textService_->showCandidates(session);
355 }
356 else {
357 textService_->hideCandidates();
358 }
359 }
360
361 const auto& candidateListVal = msg["candidateList"];
362 if (candidateListVal.isArray()) {
363 // handle candidates
364 // FIXME: directly access private member is dirty!!!
365 vector<wstring>& candidates = textService_->candidates_;
366 candidates.clear();
367 for (const auto& candidate : candidateListVal) {
368 candidates.emplace_back(utf8ToUtf16(candidate.asCString()));
369 }
370 textService_->updateCandidates(session);
371 if (!showCandidatesVal.asBool()) {
372 textService_->hideCandidates();
373 }
374 }
375
376 const auto& candidateCursorVal = msg["candidateCursor"];
377 if (candidateCursorVal.isInt()) {
378 if (textService_->candidateWindow_ != nullptr) {
379 textService_->candidateWindow_->setCurrentSel(candidateCursorVal.asInt());
380 textService_->refreshCandidates();
381 }
382 }
383}
384
385// handlers for the text service
386void Client::onActivate() {

Callers

nothing calls this directly

Calls 6

isComposingMethod · 0.80
showCandidatesMethod · 0.80
hideCandidatesMethod · 0.80
updateCandidatesMethod · 0.80
refreshCandidatesMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected