1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-25 14:52:19 +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) { public func insertText(_ object: Any, replacementRange: NSRange) {
stdoutLogger.debug("\(object) with \(replacementRange)") 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 { switch object {
case let string as String: case let string as String:
@ -149,9 +159,7 @@ extension NvimView {
stdoutLogger.debug("object: \(object), selectedRange: \(selectedRange), " + stdoutLogger.debug("object: \(object), selectedRange: \(selectedRange), " +
"replacementRange: \(replacementRange)") "replacementRange: \(replacementRange)")
if self.markedText == nil { self.markedPosition = self.ugrid.cursorPosition
self.markedPosition = self.ugrid.cursorPosition
}
Single Single
.just(replacementRange.length) .just(replacementRange.length)
@ -178,7 +186,7 @@ extension NvimView {
return Disposables.create() return Disposables.create()
} }
) )
.flatMapCompletable(self.bridge.vimInputMarkedText) .flatMapCompletable(self.bridge.vimInput)
.trigger() .trigger()
self.keyDownDone = true self.keyDownDone = true

View File

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

View File

@ -297,7 +297,8 @@ class UiBridge {
process.currentDirectoryPath = self.cwd.path process.currentDirectoryPath = self.cwd.path
process.launchPath = self.nvimServerExecutablePath() process.launchPath = self.nvimServerExecutablePath()
// GH-666: FIXME // 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() process.launch()
self.nvimServerProc = process self.nvimServerProc = process