Skip to content

Commit

Permalink
Merge pull request #102 from zonble/master
Browse files Browse the repository at this point in the history
Asks the input method to use the vertical candidate window when there is a long candidate.
  • Loading branch information
lukhnos authored Dec 26, 2023
2 parents ad11e21 + 36e26b8 commit e14464b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/McBopomofo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include "Key.h"
#include "Log.h"
#include "UTF8Helper.h"

namespace McBopomofo {

Expand Down Expand Up @@ -741,6 +742,19 @@ 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 (InputStates::ChoosingCandidate::Candidate candidate : candidates) {
std::string value = candidate.value;
if (McBopomofo::CodePointCount(value) > 8) {
return fcitx::CandidateLayoutHint::Vertical;
}
}
}

switch (config_.candidateLayout.value()) {
case McBopomofo::CandidateLayoutHint::Vertical:
layoutHint = fcitx::CandidateLayoutHint::Vertical;
Expand Down

0 comments on commit e14464b

Please # to comment.