KeyHandler // Remove errorCallback from certain handles.

This commit is contained in:
ShikiSuen 2022-07-01 09:01:58 +08:00
parent d4d9295482
commit 3d9af406cb
2 changed files with 9 additions and 13 deletions

View File

@ -303,7 +303,7 @@ extension KeyHandler {
// MARK: Esc // MARK: Esc
if input.isEsc { return handleEsc(state: state, stateCallback: stateCallback, errorCallback: errorCallback) } if input.isEsc { return handleEsc(state: state, stateCallback: stateCallback) }
// MARK: Tab // MARK: Tab
@ -379,9 +379,9 @@ extension KeyHandler {
if input.isEnter { if input.isEnter {
return (input.isCommandHold && input.isControlHold) return (input.isCommandHold && input.isControlHold)
? (input.isOptionHold ? (input.isOptionHold
? handleCtrlOptionCommandEnter(state: state, stateCallback: stateCallback, errorCallback: errorCallback) ? handleCtrlOptionCommandEnter(state: state, stateCallback: stateCallback)
: handleCtrlCommandEnter(state: state, stateCallback: stateCallback, errorCallback: errorCallback)) : handleCtrlCommandEnter(state: state, stateCallback: stateCallback))
: handleEnter(state: state, stateCallback: stateCallback, errorCallback: errorCallback) : handleEnter(state: state, stateCallback: stateCallback)
} }
// MARK: - // MARK: -
@ -408,7 +408,7 @@ extension KeyHandler {
// commit buffer ESC // commit buffer ESC
// Enter 使 commit buffer // Enter 使 commit buffer
// bool _ = // bool _ =
_ = handleEnter(state: state, stateCallback: stateCallback, errorCallback: errorCallback) _ = handleEnter(state: state, stateCallback: stateCallback)
stateCallback(InputState.SymbolTable(node: SymbolNode.root, isTypingVertical: input.isTypingVertical)) stateCallback(InputState.SymbolTable(node: SymbolNode.root, isTypingVertical: input.isTypingVertical))
return true return true
} }

View File

@ -339,8 +339,7 @@ extension KeyHandler {
/// - Returns: ctlInputMethod IMK /// - Returns: ctlInputMethod IMK
func handleEnter( func handleEnter(
state: InputStateProtocol, state: InputStateProtocol,
stateCallback: @escaping (InputStateProtocol) -> Void, stateCallback: @escaping (InputStateProtocol) -> Void
errorCallback _: @escaping () -> Void
) -> Bool { ) -> Bool {
guard let currentState = state as? InputState.Inputting else { return false } guard let currentState = state as? InputState.Inputting else { return false }
@ -359,8 +358,7 @@ extension KeyHandler {
/// - Returns: ctlInputMethod IMK /// - Returns: ctlInputMethod IMK
func handleCtrlCommandEnter( func handleCtrlCommandEnter(
state: InputStateProtocol, state: InputStateProtocol,
stateCallback: @escaping (InputStateProtocol) -> Void, stateCallback: @escaping (InputStateProtocol) -> Void
errorCallback _: @escaping () -> Void
) -> Bool { ) -> Bool {
guard state is InputState.Inputting else { return false } guard state is InputState.Inputting else { return false }
@ -390,8 +388,7 @@ extension KeyHandler {
/// - Returns: ctlInputMethod IMK /// - Returns: ctlInputMethod IMK
func handleCtrlOptionCommandEnter( func handleCtrlOptionCommandEnter(
state: InputStateProtocol, state: InputStateProtocol,
stateCallback: @escaping (InputStateProtocol) -> Void, stateCallback: @escaping (InputStateProtocol) -> Void
errorCallback _: @escaping () -> Void
) -> Bool { ) -> Bool {
guard state is InputState.Inputting else { return false } guard state is InputState.Inputting else { return false }
@ -594,8 +591,7 @@ extension KeyHandler {
/// - Returns: ctlInputMethod IMK /// - Returns: ctlInputMethod IMK
func handleEsc( func handleEsc(
state: InputStateProtocol, state: InputStateProtocol,
stateCallback: @escaping (InputStateProtocol) -> Void, stateCallback: @escaping (InputStateProtocol) -> Void
errorCallback _: @escaping () -> Void
) -> Bool { ) -> Bool {
guard state is InputState.Inputting else { return false } guard state is InputState.Inputting else { return false }