Skip to content

Commit

Permalink
Asks the input method to use the vertical candidate window when there…
Browse files Browse the repository at this point in the history
… is a long candidate.
  • Loading branch information
zonble committed Dec 26, 2023
1 parent ad11e21 commit 14fe216
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/McBopomofo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<InputStates::ChoosingCandidate*>(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;
Expand Down

0 comments on commit 14fe216

Please # to comment.