1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-24 22:33:52 +03:00

GH-666 WIP

This commit is contained in:
Tae Won Ha 2018-09-30 16:22:56 +02:00
parent 261d020385
commit fc9333b8d2
3 changed files with 18 additions and 8 deletions

View File

@ -50,6 +50,16 @@ extension NvimView {
public func insertText(_ object: Any, replacementRange: NSRange) {
stdoutLogger.debug("\(object) with \(replacementRange)")
let deleteMarkedText: Completable
if let marked = self.markedText {
let delSeq = Array(repeating: "<BS>", count: marked.count).joined()
deleteMarkedText = Single
.just(delSeq)
.flatMapCompletable { self.bridge.vimInput($0) }
} else {
deleteMarkedText = Completable.empty()
}
switch object {
case let string as String:
@ -149,9 +159,7 @@ extension NvimView {
stdoutLogger.debug("object: \(object), selectedRange: \(selectedRange), " +
"replacementRange: \(replacementRange)")
if self.markedText == nil {
self.markedPosition = self.ugrid.cursorPosition
}
self.markedPosition = self.ugrid.cursorPosition
Single
.just(replacementRange.length)
@ -178,7 +186,7 @@ extension NvimView {
return Disposables.create()
}
)
.flatMapCompletable(self.bridge.vimInputMarkedText)
.flatMapCompletable(self.bridge.vimInput)
.trigger()
self.keyDownDone = true

View File

@ -327,14 +327,11 @@ public class NvimView: NSView,
let typesetter = Typesetter()
var baselineOffset = CGFloat(0)
var markedText: String?
/// We store the last marked text because Cocoa's text input system does the following:
/// -> hanja popup -> insertText() -> attributedSubstring...() -> setMarkedText() -> ...
/// We want to return "" in attributedSubstring...()
var lastMarkedText: String?
var markedPosition = Position.null
var keyDownDone = true
var lastClickedCellPosition = Position.null
@ -363,6 +360,10 @@ public class NvimView: NSView,
let eventsSubject = PublishSubject<Event>()
let disposeBag = DisposeBag()
var markedText: String?
var markedPosition = Position.null
var markedRangeOnScreen: NSRange?
// MARK: - Private
private var _linespacing = NvimView.defaultLinespacing
}

View File

@ -297,7 +297,8 @@ class UiBridge {
process.currentDirectoryPath = self.cwd.path
process.launchPath = self.nvimServerExecutablePath()
// GH-666: FIXME
process.arguments = [self.localServerName, self.remoteServerName] + ["--headless", "/Users/hat/php.php"] + self.nvimArgs
// process.arguments = [self.localServerName, self.remoteServerName] + ["--headless", "/Users/hat/php.php"] + self.nvimArgs
process.arguments = [self.localServerName, self.remoteServerName] + ["--headless"] + self.nvimArgs
process.launch()
self.nvimServerProc = process