From 14fe2163f8c5f5f5a3292cc4394554d68d093a6a Mon Sep 17 00:00:00 2001 From: zonble Date: Tue, 26 Dec 2023 22:28:21 +0800 Subject: [PATCH] Asks the input method to use the vertical candidate window when there is a long candidate. --- src/McBopomofo.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/McBopomofo.cpp b/src/McBopomofo.cpp index a865d9d..d862972 100644 --- a/src/McBopomofo.cpp +++ b/src/McBopomofo.cpp @@ -741,6 +741,24 @@ void McBopomofoEngine::handleMarkingState(fcitx::InputContext* context, fcitx::CandidateLayoutHint McBopomofoEngine::getCandidateLayoutHint() const { fcitx::CandidateLayoutHint layoutHint = fcitx::CandidateLayoutHint::NotSet; + + auto choosingCandidate = + dynamic_cast(state_.get()); + if (choosingCandidate != nullptr) { + auto candidates = choosingCandidate->candidates; + for (auto candidate : candidates) { + if (candidate.value.length() > 8) { + return fcitx::CandidateLayoutHint::Vertical; + } + } + if (candidates.size() > 0) { + auto firstCandidate = candidates[0]; + if (firstCandidate.value.length() > 8) { + return fcitx::CandidateLayoutHint::Vertical; + } + } + } + switch (config_.candidateLayout.value()) { case McBopomofo::CandidateLayoutHint::Vertical: layoutHint = fcitx::CandidateLayoutHint::Vertical;