ctlIME // Add ctlCandidateVertical pos for horizontal typing.

This commit is contained in:
ShikiSuen 2022-06-04 14:03:36 +08:00
parent 05fbc1bf23
commit 1c3eef6400
1 changed files with 10 additions and 4 deletions

View File

@ -458,16 +458,22 @@ extension ctlInputMethod {
extension ctlInputMethod { extension ctlInputMethod {
private func show(candidateWindowWith state: InputState, client: Any!) { private func show(candidateWindowWith state: InputState, client: Any!) {
var isTypingVertical: Bool { var isTypingVertical: Bool {
var isTypingVertical = false if let state = state as? InputState.ChoosingCandidate {
return state.isTypingVertical
} else if let state = state as? InputState.AssociatedPhrases {
return state.isTypingVertical
}
return false
}
var isCandidateWindowVertical: Bool {
var candidates: [String] = [] var candidates: [String] = []
if let state = state as? InputState.ChoosingCandidate { if let state = state as? InputState.ChoosingCandidate {
isTypingVertical = state.isTypingVertical
candidates = state.candidates candidates = state.candidates
} else if let state = state as? InputState.AssociatedPhrases { } else if let state = state as? InputState.AssociatedPhrases {
isTypingVertical = state.isTypingVertical
candidates = state.candidates candidates = state.candidates
} }
if isTypingVertical { return true } if isTypingVertical { return true }
// 使
candidates.sort { candidates.sort {
$0.count > $1.count $0.count > $1.count
} }
@ -481,7 +487,7 @@ extension ctlInputMethod {
ctlCandidateCurrent.delegate = nil ctlCandidateCurrent.delegate = nil
if isTypingVertical { if isCandidateWindowVertical { // 使
ctlCandidateCurrent.currentLayout = .vertical ctlCandidateCurrent.currentLayout = .vertical
} else if mgrPrefs.useHorizontalCandidateList { } else if mgrPrefs.useHorizontalCandidateList {
ctlCandidateCurrent.currentLayout = .horizontal ctlCandidateCurrent.currentLayout = .horizontal