2016-06-04 21:45:29 +03:00
|
|
|
/**
|
|
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
|
|
* See LICENSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
public class NeoVim {
|
|
|
|
|
|
|
|
private static let qXpcName = "com.qvacua.nvox.xpc"
|
|
|
|
|
|
|
|
private let xpcConnection: NSXPCConnection = NSXPCConnection(serviceName: NeoVim.qXpcName)
|
2016-06-05 10:49:14 +03:00
|
|
|
|
2016-06-08 19:17:12 +03:00
|
|
|
public let xpc: NeoVimXpc
|
2016-06-05 10:49:14 +03:00
|
|
|
public let view: NeoVimView
|
2016-06-04 21:45:29 +03:00
|
|
|
|
|
|
|
public init() {
|
|
|
|
self.xpcConnection.remoteObjectInterface = NSXPCInterface(withProtocol: NeoVimXpc.self)
|
|
|
|
|
2016-06-08 19:17:12 +03:00
|
|
|
self.xpc = self.xpcConnection.remoteObjectProxy as! NeoVimXpc
|
|
|
|
self.view = NeoVimView(xpc: self.xpc)
|
|
|
|
|
2016-06-05 10:49:14 +03:00
|
|
|
self.xpcConnection.exportedInterface = NSXPCInterface(withProtocol: NeoVimUiBridgeProtocol.self)
|
2016-06-08 19:17:12 +03:00
|
|
|
self.xpcConnection.exportedObject = self.view
|
2016-06-04 21:45:29 +03:00
|
|
|
|
|
|
|
self.xpcConnection.resume()
|
|
|
|
|
2016-06-07 19:48:59 +03:00
|
|
|
// bring the XPC service to life
|
|
|
|
self.xpc.probe()
|
2016-06-04 21:45:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
deinit {
|
|
|
|
self.xpcConnection.invalidate()
|
|
|
|
}
|
|
|
|
|
2016-06-05 10:49:14 +03:00
|
|
|
public func vimInput(input: String) {
|
|
|
|
self.xpc.vimInput(input)
|
2016-06-04 21:45:29 +03:00
|
|
|
}
|
|
|
|
}
|