From 3d9af406cb426d3734fcb7bce84434944eb6578d Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Fri, 1 Jul 2022 09:01:58 +0800 Subject: [PATCH] KeyHandler // Remove errorCallback from certain handles. --- .../ControllerModules/KeyHandler_HandleInput.swift | 10 +++++----- .../ControllerModules/KeyHandler_States.swift | 12 ++++-------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift b/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift index 857fe3b8..c2e76076 100644 --- a/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift +++ b/Source/Modules/ControllerModules/KeyHandler_HandleInput.swift @@ -303,7 +303,7 @@ extension KeyHandler { // MARK: Esc - if input.isEsc { return handleEsc(state: state, stateCallback: stateCallback, errorCallback: errorCallback) } + if input.isEsc { return handleEsc(state: state, stateCallback: stateCallback) } // MARK: Tab @@ -379,9 +379,9 @@ extension KeyHandler { if input.isEnter { return (input.isCommandHold && input.isControlHold) ? (input.isOptionHold - ? handleCtrlOptionCommandEnter(state: state, stateCallback: stateCallback, errorCallback: errorCallback) - : handleCtrlCommandEnter(state: state, stateCallback: stateCallback, errorCallback: errorCallback)) - : handleEnter(state: state, stateCallback: stateCallback, errorCallback: errorCallback) + ? handleCtrlOptionCommandEnter(state: state, stateCallback: stateCallback) + : handleCtrlCommandEnter(state: state, stateCallback: stateCallback)) + : handleEnter(state: state, stateCallback: stateCallback) } // MARK: - @@ -408,7 +408,7 @@ extension KeyHandler { // 得在這裡先 commit buffer,不然會導致「在摁 ESC 離開符號選單時會重複輸入上一次的組字區的內容」的不當行為。 // 於是這裡用「模擬一次 Enter 鍵的操作」使其代為執行這個 commit buffer 的動作。 // 這裡不需要該函式所傳回的 bool 結果,所以用「_ =」解消掉。 - _ = handleEnter(state: state, stateCallback: stateCallback, errorCallback: errorCallback) + _ = handleEnter(state: state, stateCallback: stateCallback) stateCallback(InputState.SymbolTable(node: SymbolNode.root, isTypingVertical: input.isTypingVertical)) return true } diff --git a/Source/Modules/ControllerModules/KeyHandler_States.swift b/Source/Modules/ControllerModules/KeyHandler_States.swift index 03cfd361..c1913d93 100644 --- a/Source/Modules/ControllerModules/KeyHandler_States.swift +++ b/Source/Modules/ControllerModules/KeyHandler_States.swift @@ -339,8 +339,7 @@ extension KeyHandler { /// - Returns: 將按鍵行為「是否有處理掉」藉由 ctlInputMethod 回報給 IMK。 func handleEnter( state: InputStateProtocol, - stateCallback: @escaping (InputStateProtocol) -> Void, - errorCallback _: @escaping () -> Void + stateCallback: @escaping (InputStateProtocol) -> Void ) -> Bool { guard let currentState = state as? InputState.Inputting else { return false } @@ -359,8 +358,7 @@ extension KeyHandler { /// - Returns: 將按鍵行為「是否有處理掉」藉由 ctlInputMethod 回報給 IMK。 func handleCtrlCommandEnter( state: InputStateProtocol, - stateCallback: @escaping (InputStateProtocol) -> Void, - errorCallback _: @escaping () -> Void + stateCallback: @escaping (InputStateProtocol) -> Void ) -> Bool { guard state is InputState.Inputting else { return false } @@ -390,8 +388,7 @@ extension KeyHandler { /// - Returns: 將按鍵行為「是否有處理掉」藉由 ctlInputMethod 回報給 IMK。 func handleCtrlOptionCommandEnter( state: InputStateProtocol, - stateCallback: @escaping (InputStateProtocol) -> Void, - errorCallback _: @escaping () -> Void + stateCallback: @escaping (InputStateProtocol) -> Void ) -> Bool { guard state is InputState.Inputting else { return false } @@ -594,8 +591,7 @@ extension KeyHandler { /// - Returns: 將按鍵行為「是否有處理掉」藉由 ctlInputMethod 回報給 IMK。 func handleEsc( state: InputStateProtocol, - stateCallback: @escaping (InputStateProtocol) -> Void, - errorCallback _: @escaping () -> Void + stateCallback: @escaping (InputStateProtocol) -> Void ) -> Bool { guard state is InputState.Inputting else { return false }