1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-25 23:02:35 +03:00
This commit is contained in:
Tae Won Ha 2020-07-05 20:24:34 +02:00
parent 89233fc47e
commit 8c1207eb5b
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
3 changed files with 24 additions and 28 deletions

View File

@ -8,13 +8,12 @@ import RxSwift
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet var window: NSWindow!
@IBOutlet weak var window: NSWindow!
@IBOutlet var clientTextField: NSTextField!
@IBOutlet weak var clientTextField: NSTextField!
@IBOutlet weak var serverTextView: NSTextView!
@IBOutlet weak var clientTextView: NSTextView!
@IBOutlet var serverTextView: NSTextView!
@IBOutlet var clientTextView: NSTextView!
private let server = RxMessagePortServer()
private let client = RxMessagePortClient()
@ -23,18 +22,18 @@ class AppDelegate: NSObject, NSApplicationDelegate {
private let disposeBag = DisposeBag()
@IBAction func serverStop(sender: Any?) {
@IBAction func serverStop(sender _: Any?) {
self.server.stop().subscribe().disposed(by: self.disposeBag)
}
@IBAction func clientStop(sender: Any?) {
@IBAction func clientStop(sender _: Any?) {
self.client.stop().subscribe().disposed(by: self.disposeBag)
}
@IBAction func clientSend(sender: Any?) {
@IBAction func clientSend(sender _: Any?) {
let text = self.clientTextField.stringValue
logClient("Sending msg (\(msgid), \(text))")
self.logClient("Sending msg (\(self.msgid), \(text))")
self.client.send(msgid: self.msgid, data: text.data(using: .utf8)!, expectsReply: true)
.observeOn(MainScheduler.instance)
.subscribe(onSuccess: { data in
@ -51,7 +50,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
self.msgid += 1
}
func applicationDidFinishLaunching(_ aNotification: Notification) {
func applicationDidFinishLaunching(_: Notification) {
self
.startServer()
.andThen(self.startClient())
@ -69,13 +68,13 @@ class AppDelegate: NSObject, NSApplicationDelegate {
.disposed(by: self.disposeBag)
}
func applicationWillTerminate(_ notification: Notification) {
func applicationWillTerminate(_: Notification) {
self.client.stop().subscribe().disposed(by: self.disposeBag)
self.server.stop().subscribe().disposed(by: self.disposeBag)
}
private func startServer() -> Completable {
logServer("Starting server...")
self.logServer("Starting server...")
self.server.stream
.observeOn(MainScheduler.instance)
@ -114,7 +113,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
extension NSTextView {
func append(string: String) {
self.textStorage?.append(NSAttributedString(string: string))
self.scrollToEndOfDocument(nil)

View File

@ -3,11 +3,10 @@
* See LICENSE
*/
import XCTest
import RxSwift
import XCTest
class RxMsgpackRpcTests: XCTestCase {
private var connection: RxMsgpackRpc!
private let disposeBag = DisposeBag()
@ -15,8 +14,8 @@ class RxMsgpackRpcTests: XCTestCase {
super.setUp()
// $ NVIM_LISTEN_ADDRESS=/tmp/nvim.sock nvim --headless $SOMEFILE
connection = RxMsgpackRpc()
connection.stream
self.connection = RxMsgpackRpc()
self.connection.stream
.subscribe(onNext: { msg in
switch msg {
case let .notification(method, params):
@ -29,8 +28,8 @@ class RxMsgpackRpcTests: XCTestCase {
}, onError: { print("ERROR: \($0)") })
.disposed(by: self.disposeBag)
_ = connection.run(at: "/tmp/nvim.sock")
.andThen(connection.request(
_ = self.connection.run(at: "/tmp/nvim.sock")
.andThen(self.connection.request(
method: "nvim_ui_attach",
params: [.int(40), .int(40), .map([:])],
expectsReturnValue: true
@ -53,7 +52,7 @@ class RxMsgpackRpcTests: XCTestCase {
func testExample() {
let disposeBag = DisposeBag()
let lineCount = connection
let lineCount = self.connection
.request(
method: "nvim_buf_line_count",
params: [.int(0)],
@ -64,7 +63,7 @@ class RxMsgpackRpcTests: XCTestCase {
let formatter = DateFormatter()
formatter.dateFormat = "mm:ss.SSS"
for i in 0...100 {
for i in 0 ... 100 {
let date = Date()
connection
.request(

View File

@ -3,12 +3,11 @@
* See LICENSE
*/
import XCTest
import RxSwift
import MessagePack
import RxSwift
import XCTest
class NvimMsgPackTests: XCTestCase {
var nvim = RxNeovimApi()
let disposeBag = DisposeBag()
@ -16,7 +15,7 @@ class NvimMsgPackTests: XCTestCase {
super.setUp()
// $ NVIM_LISTEN_ADDRESS=/tmp/nvim.sock nvim $SOME_FILES
try? nvim.run(at: "/tmp/nvim.sock").wait()
try? self.nvim.run(at: "/tmp/nvim.sock").wait()
}
override func tearDown() {
@ -33,7 +32,7 @@ class NvimMsgPackTests: XCTestCase {
"Question", // blockquote foreground
]
typealias HlResult = Dictionary<String, RxNeovimApi.Value>
typealias HlResult = [String: RxNeovimApi.Value]
typealias ColorNameHlResultTuple = (colorName: String, hlResult: HlResult)
typealias ColorNameObservableTuple = (colorName: String, observable: Observable<HlResult>)
@ -82,8 +81,8 @@ class NvimMsgPackTests: XCTestCase {
formatter.timeStyle = .full
let now = Date()
let dispose = DisposeBag()
for i in 0...5 {
nvim
for i in 0 ... 5 {
self.nvim
.command(
command: "echo '\(formatter.string(from: now)) \(i)'"
)