diff --git a/Source/Modules/ControllerModules/KeyHandler_Core.swift b/Source/Modules/ControllerModules/KeyHandler_Core.swift index 7c8f8fe7..7124b2b9 100644 --- a/Source/Modules/ControllerModules/KeyHandler_Core.swift +++ b/Source/Modules/ControllerModules/KeyHandler_Core.swift @@ -18,6 +18,7 @@ import Cocoa /// KeyHandler 委任協定 protocol KeyHandlerDelegate { + var clientBundleIdentifier: String { get } func ctlCandidate() -> ctlCandidateProtocol func keyHandler( _: KeyHandler, didSelectCandidateAt index: Int, diff --git a/Source/Modules/ControllerModules/KeyHandler_States.swift b/Source/Modules/ControllerModules/KeyHandler_States.swift index 755c3f9b..1b00d39c 100644 --- a/Source/Modules/ControllerModules/KeyHandler_States.swift +++ b/Source/Modules/ControllerModules/KeyHandler_States.swift @@ -347,7 +347,7 @@ extension KeyHandler { composingBuffer = Tekkon.cnvPhonaToHanyuPinyin(target: composingBuffer) // 注音轉拼音 } - if !IME.areWeUsingOurOwnPhraseEditor { + if let delegate = delegate, !delegate.clientBundleIdentifier.contains("vChewingPhraseEditor") { composingBuffer = composingBuffer.replacingOccurrences(of: "-", with: " ") } diff --git a/Source/Modules/ControllerModules/ctlInputMethod_Core.swift b/Source/Modules/ControllerModules/ctlInputMethod_Core.swift index c66603e7..b8d2b781 100644 --- a/Source/Modules/ControllerModules/ctlInputMethod_Core.swift +++ b/Source/Modules/ControllerModules/ctlInputMethod_Core.swift @@ -39,6 +39,7 @@ class ctlInputMethod: IMKInputController { var state: InputStateProtocol = InputState.Empty() /// 當前這個 ctlInputMethod 副本是否處於英數輸入模式。 var isASCIIMode: Bool = false + /// 記錄當前輸入環境是縱排輸入還是橫排輸入。 public var isVerticalTyping: Bool { guard let client = client() else { return false } @@ -233,15 +234,6 @@ class ctlInputMethod: IMKInputController { // 準備修飾鍵,用來判定要新增的詞彙是否需要賦以非常低的權重。 ctlInputMethod.areWeNerfing = event.modifierFlags.contains([.shift, .command]) - if let client = client(), - client.bundleIdentifier() - == "org.atelierInmu.vChewing.vChewingPhraseEditor" - { - IME.areWeUsingOurOwnPhraseEditor = true - } else { - IME.areWeUsingOurOwnPhraseEditor = false - } - var input = InputSignal(event: event, isVerticalTyping: isVerticalTyping) input.isASCIIModeInput = isASCIIMode diff --git a/Source/Modules/ControllerModules/ctlInputMethod_Delegates.swift b/Source/Modules/ControllerModules/ctlInputMethod_Delegates.swift index 17cdd209..a105f42e 100644 --- a/Source/Modules/ControllerModules/ctlInputMethod_Delegates.swift +++ b/Source/Modules/ControllerModules/ctlInputMethod_Delegates.swift @@ -13,6 +13,8 @@ import Cocoa // MARK: - KeyHandler Delegate extension ctlInputMethod: KeyHandlerDelegate { + var clientBundleIdentifier: String { client()?.bundleIdentifier() ?? "" } + func ctlCandidate() -> ctlCandidateProtocol { ctlInputMethod.ctlCandidateCurrent } func keyHandler( @@ -84,15 +86,6 @@ extension ctlInputMethod: ctlCandidateDelegate { // 準備修飾鍵,用來判定要新增的詞彙是否需要賦以非常低的權重。 ctlInputMethod.areWeNerfing = event.modifierFlags.contains([.shift, .command]) - if let client = client(), - client.bundleIdentifier() - == "org.atelierInmu.vChewing.vChewingPhraseEditor" - { - IME.areWeUsingOurOwnPhraseEditor = true - } else { - IME.areWeUsingOurOwnPhraseEditor = false - } - var input = InputSignal(event: event, isVerticalTyping: isVerticalTyping) input.isASCIIModeInput = isASCIIMode diff --git a/Source/Modules/IMEModules/IME.swift b/Source/Modules/IMEModules/IME.swift index 24e52104..afd99eec 100644 --- a/Source/Modules/IMEModules/IME.swift +++ b/Source/Modules/IMEModules/IME.swift @@ -40,10 +40,6 @@ public enum IME { return text } - // MARK: - 開關判定當前應用究竟是? - - static var areWeUsingOurOwnPhraseEditor: Bool = false - // MARK: - 自 ctlInputMethod 讀取當前輸入法的簡繁體模式 static func getInputMode(isReversed: Bool = false) -> InputMode {