| 342 | } |
| 343 | |
| 344 | void 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 |
| 386 | void Client::onActivate() { |
nothing calls this directly
no test coverage detected