InputHandler // Introduce hotkeys for candidate manipulation.

This commit is contained in:
ShikiSuen 2023-06-04 16:43:17 +08:00
parent bf8d9f30f0
commit bea40d7e75
1 changed files with 25 additions and 0 deletions

View File

@ -25,6 +25,31 @@ extension InputHandler {
let state = delegate.state
guard !state.candidates.isEmpty else { return false }
// MARK: 使
manipulator: if (delegate as? CtlCandidateDelegate)?.isCandidateContextMenuEnabled ?? false {
// IMKCandidates 使 IMK
if prefs.useIMKCandidateWindow { break manipulator }
let candidates = state.candidates
let highlightedIndex = ctlCandidate.highlightedIndex
if !(0 ..< candidates.count).contains(ctlCandidate.highlightedIndex) { break manipulator }
if candidates[highlightedIndex].keyArray.count < 2 || candidates[highlightedIndex].value.count < 2 {
break manipulator
}
switch input.modifierFlags {
case [.option, .command] where input.keyCode == 27: //
ctlCandidate.delegate?.candidatePairRightClicked(at: highlightedIndex, action: .toNerf)
return true
case [.option, .command] where input.keyCode == 24: // JIS ^
ctlCandidate.delegate?.candidatePairRightClicked(at: highlightedIndex, action: .toBoost)
return true
case _ where input.isOptionHold && input.isCommandHold && input.isDelete:
ctlCandidate.delegate?.candidatePairRightClicked(at: highlightedIndex, action: .toFilter)
return true
default: break
}
}
// MARK: (Cancel Candidate)
let cancelCandidateKey =