11//
2- // MarkEditWritingTools .swift
2+ // AppWritingTools .swift
33// MarkEditMac
44//
55// Created by cyan on 8/14/24.
@@ -23,11 +23,10 @@ enum WritingTool: Int {
2323}
2424
2525@available ( macOS 15 . 1 , * )
26- enum MarkEditWritingTools {
26+ enum AppWritingTools {
2727 static var requestedTool : WritingTool {
2828 for window in NSApp . windows {
29- guard let controller = window. contentViewController,
30- controller. className == " WTWritingToolsViewController " else {
29+ guard let controller = window. contentViewController, controller. className == " WTWritingToolsViewController " else {
3130 continue
3231 }
3332
@@ -39,11 +38,12 @@ enum MarkEditWritingTools {
3938 return controller
4039 }
4140
42- let impl = unsafeBitCast (
41+ let invocation = unsafeBitCast (
4342 controller. method ( for: configSelector) ,
4443 to: ( @convention( c) ( NSObject, Selector) - > NSObject? ) . self
4544 )
46- return impl ( controller, configSelector) ?? controller
45+
46+ return invocation ( controller, configSelector) ?? controller
4747 } ( )
4848
4949 let toolSelector = sel_getUid ( " requestedTool " )
@@ -52,24 +52,27 @@ enum MarkEditWritingTools {
5252 return . panel
5353 }
5454
55- let impl = unsafeBitCast (
55+ let invocation = unsafeBitCast (
5656 target. method ( for: toolSelector) ,
5757 to: ( @convention( c) ( NSObject, Selector) - > Int) . self
5858 )
5959
60- return WritingTool ( rawValue: impl ( target, toolSelector) ) ?? . panel
60+ return WritingTool ( rawValue: invocation ( target, toolSelector) ) ?? . panel
6161 }
6262
6363 return . panel
6464 }
6565
6666 static var affordanceIcon : NSImage ? {
67- let configuration = NSImage . SymbolConfiguration ( pointSize: 12.5 , weight: . medium)
68- let symbolImage = NSImage ( systemSymbolName: " apple.writing.tools " , accessibilityDescription: nil )
69- ?? NSImage ( systemSymbolName: " _gm " , accessibilityDescription: nil )
67+ let configuration = NSImage . SymbolConfiguration (
68+ pointSize: 12.5 ,
69+ weight: . medium
70+ )
7071
71- if let symbolImage {
72- return symbolImage. withSymbolConfiguration ( configuration)
72+ for symbolName in [ " apple.writing.tools " , " _gm " ] {
73+ if let symbolImage = NSImage ( systemSymbolName: symbolName, accessibilityDescription: nil ) {
74+ return symbolImage. withSymbolConfiguration ( configuration)
75+ }
7376 }
7477
7578 guard let affordanceClass = NSClassFromString ( " WTAffordanceView " ) as? NSView . Type else {
@@ -103,7 +106,7 @@ enum MarkEditWritingTools {
103106// MARK: - Private
104107
105108@available ( macOS 15 . 1 , * )
106- private extension MarkEditWritingTools {
109+ private extension AppWritingTools {
107110 static var writingToolsInstance : NSObject ? {
108111 guard let cls = NSClassFromString ( " WTWritingTools " ) else {
109112 assertionFailure ( " Failed to get WTWritingTools class " )
@@ -116,12 +119,12 @@ private extension MarkEditWritingTools {
116119 return nil
117120 }
118121
119- let impl = unsafeBitCast (
122+ let invocation = unsafeBitCast (
120123 method_getImplementation ( classMethod) ,
121124 to: ( @convention( c) ( AnyObject, Selector) - > NSObject? ) . self
122125 )
123- let instance = impl ( cls as AnyObject , selector)
124126
127+ let instance = invocation ( cls as AnyObject , selector)
125128 assert ( instance != nil , " Failed to get WTWritingTools instance " )
126129 return instance
127130 }
0 commit comments