mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-27 15:53:31 +03:00
64 lines
1.3 KiB
Swift
64 lines
1.3 KiB
Swift
/**
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
* See LICENSE
|
|
*/
|
|
|
|
import Foundation
|
|
|
|
public class NeoVim {
|
|
|
|
enum UiEvent {
|
|
case MoveCursor(position: Position)
|
|
case Put(string: String)
|
|
case Resize(size: Size)
|
|
}
|
|
|
|
struct Size {
|
|
let rows: Int32
|
|
let columns: Int32
|
|
}
|
|
|
|
struct Position {
|
|
let row: Int32
|
|
let column: Int32
|
|
}
|
|
|
|
enum ColorKind {
|
|
case Foreground
|
|
case Background
|
|
case Special
|
|
}
|
|
|
|
private static let qXpcName = "com.qvacua.nvox.xpc"
|
|
|
|
private let xpcConnection: NSXPCConnection = NSXPCConnection(serviceName: NeoVim.qXpcName)
|
|
private let xpc: NeoVimXpc
|
|
|
|
private let neoVimUiBridge: NeoVimUiBridge
|
|
|
|
public let view: NeoVimView
|
|
|
|
public init() {
|
|
let neoVimUiBridge = NeoVimUiBridge()
|
|
self.neoVimUiBridge = neoVimUiBridge
|
|
self.view = NeoVimView(uiEventObservable: neoVimUiBridge.observable)
|
|
|
|
self.xpcConnection.remoteObjectInterface = NSXPCInterface(withProtocol: NeoVimXpc.self)
|
|
|
|
self.xpcConnection.exportedInterface = NSXPCInterface(withProtocol: NeoVimUiBridgeProtocol.self)
|
|
self.xpcConnection.exportedObject = self.neoVimUiBridge
|
|
|
|
self.xpcConnection.resume()
|
|
|
|
self.xpc = self.xpcConnection.remoteObjectProxy as! NeoVimXpc
|
|
}
|
|
|
|
deinit {
|
|
self.xpcConnection.invalidate()
|
|
}
|
|
|
|
public func vimInput(input: String) {
|
|
self.xpc.vimInput(input)
|
|
}
|
|
}
|