diff --git a/Source/Modules/ControllerModules/KeyHandler_Core.swift b/Source/Modules/ControllerModules/KeyHandler_Core.swift index 8ac1887d..09016f4c 100644 --- a/Source/Modules/ControllerModules/KeyHandler_Core.swift +++ b/Source/Modules/ControllerModules/KeyHandler_Core.swift @@ -19,6 +19,7 @@ import Foundation /// KeyHandler 委任協定 protocol KeyHandlerDelegate { var clientBundleIdentifier: String { get } + var isVerticalTyping: Bool { get } func ctlCandidate() -> ctlCandidateProtocol func keyHandler( _: KeyHandler, didSelectCandidateAt index: Int, diff --git a/Source/Modules/ControllerModules/ctlInputMethod_Core.swift b/Source/Modules/ControllerModules/ctlInputMethod_Core.swift index 99cf1603..dab2ccf2 100644 --- a/Source/Modules/ControllerModules/ctlInputMethod_Core.swift +++ b/Source/Modules/ControllerModules/ctlInputMethod_Core.swift @@ -39,16 +39,6 @@ class ctlInputMethod: IMKInputController { /// 當前這個 ctlInputMethod 副本是否處於英數輸入模式。 var isASCIIMode: Bool = false - /// 記錄當前輸入環境是縱排輸入還是橫排輸入。 - public var isVerticalTyping: Bool { - guard let client = client() else { return false } - var textFrame = NSRect.zero - let attributes: [AnyHashable: Any]? = client.attributes( - forCharacterIndex: 0, lineHeightRectangle: &textFrame - ) - return (attributes?["IMKTextOrientation"] as? NSNumber)?.intValue == 0 || false - } - /// 切換當前 ctlInputMethod 副本的英數輸入模式開關。 func toggleASCIIMode() -> Bool { resetKeyHandler() diff --git a/Source/Modules/ControllerModules/ctlInputMethod_Delegates.swift b/Source/Modules/ControllerModules/ctlInputMethod_Delegates.swift index 1d634e75..d0746aa4 100644 --- a/Source/Modules/ControllerModules/ctlInputMethod_Delegates.swift +++ b/Source/Modules/ControllerModules/ctlInputMethod_Delegates.swift @@ -13,6 +13,16 @@ import Cocoa // MARK: - KeyHandler Delegate extension ctlInputMethod: KeyHandlerDelegate { + /// 記錄當前輸入環境是縱排輸入還是橫排輸入。 + public var isVerticalTyping: Bool { + guard let client = client() else { return false } + var textFrame = NSRect.zero + let attributes: [AnyHashable: Any]? = client.attributes( + forCharacterIndex: 0, lineHeightRectangle: &textFrame + ) + return (attributes?["IMKTextOrientation"] as? NSNumber)?.intValue == 0 || false + } + var clientBundleIdentifier: String { guard let client = client() else { return "" } return client.bundleIdentifier() ?? ""