diff --git a/Source/Modules/InputHandler_Core.swift b/Source/Modules/InputHandler_Core.swift index 5f3d064d..05d449a1 100644 --- a/Source/Modules/InputHandler_Core.swift +++ b/Source/Modules/InputHandler_Core.swift @@ -22,7 +22,9 @@ public protocol InputHandlerProtocol { var currentUOM: vChewingLM.LMUserOverride { get set } var delegate: InputHandlerDelegate? { get set } var composer: Tekkon.Composer { get set } + var isComposerUsingPinyin: Bool { get } func clear() + func clearComposerAndCalligrapher() func ensureKeyboardParser() func handleEvent(_ event: NSEvent) -> Bool func generateStateOfInputting() -> IMEStateProtocol @@ -82,9 +84,8 @@ public class InputHandler: InputHandlerProtocol { } public func clear() { - composer.clear() + clearComposerAndCalligrapher() compositor.clear() - calligrapher.removeAll() } // MARK: - Functions dealing with Megrez. @@ -367,8 +368,11 @@ public class InputHandler: InputHandlerProtocol { composer.phonabetCombinationCorrectionEnabled = prefs.autoCorrectReadingCombination } - func clearComposerAndCalligrapher() { - _ = prefs.cassetteEnabled ? calligrapher.removeAll() : composer.clear() + public var isComposerUsingPinyin: Bool { composer.parser.rawValue >= 100 } + + public func clearComposerAndCalligrapher() { + calligrapher.removeAll() + composer.clear() } func letComposerAndCalligrapherDoBackSpace() { diff --git a/Source/Modules/SessionCtl_Core.swift b/Source/Modules/SessionCtl_Core.swift index 3d99c1ad..3e3fe8d6 100644 --- a/Source/Modules/SessionCtl_Core.swift +++ b/Source/Modules/SessionCtl_Core.swift @@ -169,7 +169,7 @@ extension SessionCtl { public func resetInputHandler() { // 過濾掉尚未完成拼寫的注音。 if state.type == .ofInputting, PrefMgr.shared.trimUnfinishedReadingsOnCommit { - inputHandler.composer.clear() + inputHandler.clearComposerAndCalligrapher() switchState(inputHandler.generateStateOfInputting()) } // 威注音不再在這裡對 IMKTextInput 客體黑名單當中的應用做資安措施。 diff --git a/Source/Modules/SessionCtl_HandleEvent.swift b/Source/Modules/SessionCtl_HandleEvent.swift index c0c95793..63f85908 100644 --- a/Source/Modules/SessionCtl_HandleEvent.swift +++ b/Source/Modules/SessionCtl_HandleEvent.swift @@ -117,7 +117,7 @@ extension SessionCtl { } // 在啟用注音排列而非拼音輸入的情況下,強制將當前鍵盤佈局翻譯為美規鍵盤。 - if inputHandler.composer.parser.rawValue < 100 || IMKHelper.isDynamicBasicKeyboardLayoutEnabled { + if !inputHandler.isComposerUsingPinyin || IMKHelper.isDynamicBasicKeyboardLayoutEnabled { eventToDeal = eventToDeal.inAppleABCStaticForm }