ctlIME // Move isVerticalTyping to KeyHandlerDelegate.

This commit is contained in:
ShikiSuen 2022-08-27 22:54:28 +08:00
parent 1927d1ca74
commit a0400c111a
3 changed files with 11 additions and 10 deletions

View File

@ -19,6 +19,7 @@ import Foundation
/// KeyHandler /// KeyHandler
protocol KeyHandlerDelegate { protocol KeyHandlerDelegate {
var clientBundleIdentifier: String { get } var clientBundleIdentifier: String { get }
var isVerticalTyping: Bool { get }
func ctlCandidate() -> ctlCandidateProtocol func ctlCandidate() -> ctlCandidateProtocol
func keyHandler( func keyHandler(
_: KeyHandler, didSelectCandidateAt index: Int, _: KeyHandler, didSelectCandidateAt index: Int,

View File

@ -39,16 +39,6 @@ class ctlInputMethod: IMKInputController {
/// ctlInputMethod /// ctlInputMethod
var isASCIIMode: Bool = false 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 /// ctlInputMethod
func toggleASCIIMode() -> Bool { func toggleASCIIMode() -> Bool {
resetKeyHandler() resetKeyHandler()

View File

@ -13,6 +13,16 @@ import Cocoa
// MARK: - KeyHandler Delegate // MARK: - KeyHandler Delegate
extension ctlInputMethod: KeyHandlerDelegate { 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 { var clientBundleIdentifier: String {
guard let client = client() else { return "" } guard let client = client() else { return "" }
return client.bundleIdentifier() ?? "" return client.bundleIdentifier() ?? ""