File tree Expand file tree Collapse file tree 7 files changed +231
-53
lines changed
xcuserdata/cyandev.xcuserdatad/xcschemes Expand file tree Collapse file tree 7 files changed +231
-53
lines changed Original file line number Diff line number Diff line change 88
99import Foundation
1010
11- struct KeyEvent {
11+ /*
12+ public struct KeyEvent {
1213
13- enum Key {
14+ public enum Key {
1415 case up
1516 case down
1617 case left
1718 case right
1819 }
1920
20- let `repeat` : Bool
21- let key : Key
21+ public let `repeat`: Bool
22+ public let key: Key
2223
2324}
25+ */
2426
25- typealias KeyEventListener = ( KeyEvent ) -> ( )
27+ public typealias KeyEventListener = ( Bool , UInt16 ) -> ( )
2628
2729// The main interface that app side interacts with.
28- protocol AppKitSupports : class {
30+ public protocol AppKitSupports : class {
2931
3032 func monitorKeyDown( _ listener: @escaping KeyEventListener )
3133
@@ -37,11 +39,11 @@ protocol AppKitSupports : class {
3739//
3840// We don't want to perform any symbol resolution (via `dlsym`), so this is
3941// a must.
40- class AppKitSupportsFacade : NSObject {
42+ public class AppKitSupportsFacade : NSObject {
4143
42- override required init ( ) { }
44+ public override required init ( ) { }
4345
44- @objc func getImpl( ) -> UnsafeRawPointer {
46+ @objc public func getImpl( ) -> UnsafeRawPointer {
4547 fatalError ( " Stub is called " )
4648 }
4749
Original file line number Diff line number Diff line change @@ -10,31 +10,11 @@ import AppKit
1010
1111class _AppKitSupportsImpl : AppKitSupports {
1212
13- fileprivate static let shared = _AppKitSupportsImpl ( )
13+ fileprivate static var shared : AppKitSupports = _AppKitSupportsImpl ( )
1414
15- func monitorKeyDown( _ listener: @escaping ( KeyEvent ) -> ( ) ) {
15+ func monitorKeyDown( _ listener: @escaping ( Bool , UInt16 ) -> ( ) ) {
1616 NSEvent . addLocalMonitorForEvents ( matching: . keyDown) { e -> NSEvent ? in
17- let key : KeyEvent . Key
18- switch e. keyCode {
19- case 126 :
20- key = . up
21- break
22- case 125 :
23- key = . down
24- break
25- case 123 :
26- key = . left
27- break
28- case 124 :
29- key = . right
30- break
31- default :
32- return e
33- }
34-
35- let event = KeyEvent ( repeat : e. isARepeat, key: key)
36- listener ( event)
37-
17+ listener ( e. isARepeat, e. keyCode)
3818 return e
3919 }
4020 }
@@ -46,8 +26,9 @@ class _AppKitSupportsFacadeImpl : AppKitSupportsFacade {
4626 required init ( ) { }
4727
4828 @objc override func getImpl( ) -> UnsafeRawPointer {
49- var impl : AppKitSupports = _AppKitSupportsImpl. shared
50- return withUnsafePointer ( to: & impl) { UnsafeRawPointer ( $0) }
29+ return withUnsafePointer ( to: & _AppKitSupportsImpl. shared) {
30+ UnsafeRawPointer ( $0)
31+ }
5132 }
5233
5334}
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+ <plist version =" 1.0" >
4+ <dict >
5+ <key >CFBundleDevelopmentRegion </key >
6+ <string >$(DEVELOPMENT_LANGUAGE) </string >
7+ <key >CFBundleExecutable </key >
8+ <string >$(EXECUTABLE_NAME) </string >
9+ <key >CFBundleIdentifier </key >
10+ <string >$(PRODUCT_BUNDLE_IDENTIFIER) </string >
11+ <key >CFBundleInfoDictionaryVersion </key >
12+ <string >6.0 </string >
13+ <key >CFBundleName </key >
14+ <string >$(PRODUCT_NAME) </string >
15+ <key >CFBundlePackageType </key >
16+ <string >$(PRODUCT_BUNDLE_PACKAGE_TYPE) </string >
17+ <key >CFBundleShortVersionString </key >
18+ <string >1.0 </string >
19+ <key >CFBundleVersion </key >
20+ <string >$(CURRENT_PROJECT_VERSION) </string >
21+ </dict >
22+ </plist >
You can’t perform that action at this time.
0 commit comments