IMKCandidates // Use InputSignalProtocol.

This commit is contained in:
ShikiSuen 2022-09-01 14:09:33 +08:00
parent 95abbea039
commit ee6b77001a
1 changed files with 15 additions and 16 deletions

View File

@ -206,25 +206,24 @@ public class ctlCandidateIMK: IMKCandidates, ctlCandidateProtocol {
// Objective-C nil // Objective-C nil
guard !eventArray.isEmpty else { return } guard !eventArray.isEmpty else { return }
let event = eventArray[0] let event = eventArray[0]
let input = InputSignal(event: event)
guard let delegate = delegate else { return } guard let delegate = delegate else { return }
if input.isEsc || input.isBackSpace || input.isDelete || (input.isShiftHold && !input.isSpace) { if event.isEsc || event.isBackSpace || event.isDelete || (event.isShiftHold && !event.isSpace) {
_ = delegate.sharedEventHandler(event) _ = delegate.sharedEventHandler(event)
} else if input.isSymbolMenuPhysicalKey { } else if event.isSymbolMenuPhysicalKey {
// //
switch currentLayout { switch currentLayout {
case .horizontal: input.isShiftHold ? moveUp(self) : moveDown(self) case .horizontal: event.isShiftHold ? moveUp(self) : moveDown(self)
case .vertical: input.isShiftHold ? moveLeft(self) : moveRight(self) case .vertical: event.isShiftHold ? moveLeft(self) : moveRight(self)
} }
} else if input.isSpace { } else if event.isSpace {
switch mgrPrefs.specifyShiftSpaceKeyBehavior { switch mgrPrefs.specifyShiftSpaceKeyBehavior {
case true: _ = input.isShiftHold ? highlightNextCandidate() : showNextPage() case true: _ = event.isShiftHold ? highlightNextCandidate() : showNextPage()
case false: _ = input.isShiftHold ? showNextPage() : highlightNextCandidate() case false: _ = event.isShiftHold ? showNextPage() : highlightNextCandidate()
} }
} else if input.isTab { } else if event.isTab {
switch mgrPrefs.specifyShiftTabKeyBehavior { switch mgrPrefs.specifyShiftTabKeyBehavior {
case true: _ = input.isShiftHold ? showPreviousPage() : showNextPage() case true: _ = event.isShiftHold ? showPreviousPage() : showNextPage()
case false: _ = input.isShiftHold ? highlightPreviousCandidate() : highlightNextCandidate() case false: _ = event.isShiftHold ? highlightPreviousCandidate() : highlightNextCandidate()
} }
} else { } else {
if let newChar = ctlCandidateIMK.defaultIMKSelectionKey[event.keyCode] { if let newChar = ctlCandidateIMK.defaultIMKSelectionKey[event.keyCode] {
@ -245,7 +244,7 @@ public class ctlCandidateIMK: IMKCandidates, ctlCandidateProtocol {
if let newEvent = newEvent { if let newEvent = newEvent {
if mgrPrefs.useSCPCTypingMode, delegate.isAssociatedPhrasesState { if mgrPrefs.useSCPCTypingMode, delegate.isAssociatedPhrasesState {
// input.isShiftHold ctlInputMethod.handle() // input.isShiftHold ctlInputMethod.handle()
if !input.isShiftHold { if !event.isShiftHold {
_ = delegate.sharedEventHandler(event) _ = delegate.sharedEventHandler(event)
return return
} }
@ -256,15 +255,15 @@ public class ctlCandidateIMK: IMKCandidates, ctlCandidateProtocol {
} }
} }
if mgrPrefs.useSCPCTypingMode, !input.isReservedKey { if mgrPrefs.useSCPCTypingMode, !event.isReservedKey {
_ = delegate.sharedEventHandler(event) _ = delegate.sharedEventHandler(event)
return return
} }
if delegate.isAssociatedPhrasesState, if delegate.isAssociatedPhrasesState,
!input.isPageUp, !input.isPageDown, !input.isCursorForward, !input.isCursorBackward, !event.isPageUp, !event.isPageDown, !event.isCursorForward, !event.isCursorBackward,
!input.isCursorClockLeft, !input.isCursorClockRight, !input.isSpace, !event.isCursorClockLeft, !event.isCursorClockRight, !event.isSpace,
!input.isEnter || !mgrPrefs.alsoConfirmAssociatedCandidatesByEnter !event.isEnter || !mgrPrefs.alsoConfirmAssociatedCandidatesByEnter
{ {
_ = delegate.sharedEventHandler(event) _ = delegate.sharedEventHandler(event)
return return