mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-26 21:55:21 +03:00
add tentative tcd lcd support
This commit is contained in:
parent
efb9a5fc60
commit
3c7b75a26b
@ -58,6 +58,8 @@ public extension NvimView {
|
|||||||
case setTitle(String)
|
case setTitle(String)
|
||||||
case setDirtyStatus(Bool)
|
case setDirtyStatus(Bool)
|
||||||
case cwdChanged
|
case cwdChanged
|
||||||
|
case tcwdChanged
|
||||||
|
case lcwdChanged
|
||||||
case bufferListChanged
|
case bufferListChanged
|
||||||
case tabChanged
|
case tabChanged
|
||||||
|
|
||||||
|
@ -333,13 +333,21 @@ extension NvimView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if event == .dirchanged {
|
if event == .dirchanged {
|
||||||
guard array.count > 1,
|
guard array.count > 2,
|
||||||
array[1].stringValue != nil
|
array[1].stringValue != nil,
|
||||||
|
let scope = array[2].stringValue
|
||||||
else {
|
else {
|
||||||
self.bridgeLogger.error("Could not convert \(array)")
|
self.bridgeLogger.error("Could not convert \(array)")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.cwdChanged(array[1])
|
|
||||||
|
if scope == "tabpage" {
|
||||||
|
self.tcwdChanged(array[1])
|
||||||
|
} else if scope == "window" {
|
||||||
|
self.lcwdChanged(array[1])
|
||||||
|
} else {
|
||||||
|
self.cwdChanged(array[1])
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,6 +580,28 @@ extension NvimView {
|
|||||||
self.eventsSubject.onNext(.cwdChanged)
|
self.eventsSubject.onNext(.cwdChanged)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final func tcwdChanged(_ value: MessagePackValue) {
|
||||||
|
guard let cwd = value.stringValue else {
|
||||||
|
self.bridgeLogger.error("Could not convert \(value)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
self.bridgeLogger.debug(cwd)
|
||||||
|
self._cwd = URL(fileURLWithPath: cwd)
|
||||||
|
self.eventsSubject.onNext(.tcwdChanged)
|
||||||
|
}
|
||||||
|
|
||||||
|
final func lcwdChanged(_ value: MessagePackValue) {
|
||||||
|
guard let cwd = value.stringValue else {
|
||||||
|
self.bridgeLogger.error("Could not convert \(value)")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
self.bridgeLogger.debug(cwd)
|
||||||
|
self._cwd = URL(fileURLWithPath: cwd)
|
||||||
|
self.eventsSubject.onNext(.lcwdChanged)
|
||||||
|
}
|
||||||
|
|
||||||
final func colorSchemeChanged(_ value: MessagePackValue) {
|
final func colorSchemeChanged(_ value: MessagePackValue) {
|
||||||
guard let values = MessagePackUtils.array(
|
guard let values = MessagePackUtils.array(
|
||||||
from: value, ofSize: 5, conversion: { $0.intValue }
|
from: value, ofSize: 5, conversion: { $0.intValue }
|
||||||
|
@ -40,7 +40,7 @@ public protocol NvimViewDelegate: AnyObject {
|
|||||||
|
|
||||||
public final class NvimView: NSView, NSUserInterfaceValidations, NSTextInputClient {
|
public final class NvimView: NSView, NSUserInterfaceValidations, NSTextInputClient {
|
||||||
// MARK: - Public
|
// MARK: - Public
|
||||||
|
|
||||||
public static let rpcEventName = "com.qvacua.NvimView"
|
public static let rpcEventName = "com.qvacua.NvimView"
|
||||||
|
|
||||||
public static let minFontSize = 4.0
|
public static let minFontSize = 4.0
|
||||||
@ -142,6 +142,36 @@ public final class NvimView: NSView, NSUserInterfaceValidations, NSTextInputClie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var tcwd: URL {
|
||||||
|
get { self._cwd }
|
||||||
|
|
||||||
|
set {
|
||||||
|
self.api
|
||||||
|
.exec2(src:"tcd \(newValue.path)", opts: [:])
|
||||||
|
.subscribe(on: self.scheduler)
|
||||||
|
.subscribe(onFailure: { [weak self] error in
|
||||||
|
self?.eventsSubject
|
||||||
|
.onError(Error.ipc(msg: "Could not set cwd to \(newValue)", cause: error))
|
||||||
|
})
|
||||||
|
.disposed(by: self.disposeBag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public var lcwd: URL {
|
||||||
|
get { self._cwd }
|
||||||
|
|
||||||
|
set {
|
||||||
|
self.api
|
||||||
|
.exec2(src:"lcd \(newValue.path)", opts: [:])
|
||||||
|
.subscribe(on: self.scheduler)
|
||||||
|
.subscribe(onFailure: { [weak self] error in
|
||||||
|
self?.eventsSubject
|
||||||
|
.onError(Error.ipc(msg: "Could not set cwd to \(newValue)", cause: error))
|
||||||
|
})
|
||||||
|
.disposed(by: self.disposeBag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public var defaultCellAttributes: CellAttributes {
|
public var defaultCellAttributes: CellAttributes {
|
||||||
self.cellAttributesCollection.defaultAttributes
|
self.cellAttributesCollection.defaultAttributes
|
||||||
}
|
}
|
||||||
@ -375,7 +405,7 @@ public final class NvimView: NSView, NSUserInterfaceValidations, NSTextInputClie
|
|||||||
autocmd TabEnter * call rpcnotify(\(channel), 'autocommand', 'tabenter', str2nr(expand('<abuf>')))
|
autocmd TabEnter * call rpcnotify(\(channel), 'autocommand', 'tabenter', str2nr(expand('<abuf>')))
|
||||||
autocmd BufWritePost * call rpcnotify(\(channel), 'autocommand', 'bufwritepost', str2nr(expand('<abuf>')))
|
autocmd BufWritePost * call rpcnotify(\(channel), 'autocommand', 'bufwritepost', str2nr(expand('<abuf>')))
|
||||||
autocmd BufEnter * call rpcnotify(\(channel), 'autocommand', 'bufenter', str2nr(expand('<abuf>')))
|
autocmd BufEnter * call rpcnotify(\(channel), 'autocommand', 'bufenter', str2nr(expand('<abuf>')))
|
||||||
autocmd DirChanged * call rpcnotify(\( channel), 'autocommand', 'dirchanged', expand('<afile>'))
|
autocmd DirChanged * call rpcnotify(\( channel), 'autocommand', 'dirchanged', expand('<afile>'), v:event['scope'])
|
||||||
autocmd BufModifiedSet * call rpcnotify(\(channel), 'autocommand', 'bufmodifiedset', str2nr(expand('<abuf>')), getbufinfo(str2nr(expand('<abuf>')))[0].changed)
|
autocmd BufModifiedSet * call rpcnotify(\(channel), 'autocommand', 'bufmodifiedset', str2nr(expand('<abuf>')), getbufinfo(str2nr(expand('<abuf>')))[0].changed)
|
||||||
""", opts: [:], errWhenBlocked: false)
|
""", opts: [:], errWhenBlocked: false)
|
||||||
// swiftformat:enable all
|
// swiftformat:enable all
|
||||||
|
@ -112,6 +112,8 @@ final class Context: ReduxContext {
|
|||||||
private func cleanUpAppState() {
|
private func cleanUpAppState() {
|
||||||
self.state.mainWindows.keys.forEach { uuid in
|
self.state.mainWindows.keys.forEach { uuid in
|
||||||
self.state.mainWindows[uuid]?.cwdToSet = nil
|
self.state.mainWindows[uuid]?.cwdToSet = nil
|
||||||
|
self.state.mainWindows[uuid]?.tcwdToSet = nil
|
||||||
|
self.state.mainWindows[uuid]?.lcwdToSet = nil
|
||||||
self.state.mainWindows[uuid]?.currentBufferToSet = nil
|
self.state.mainWindows[uuid]?.currentBufferToSet = nil
|
||||||
self.state.mainWindows[uuid]?.viewToBeFocused = nil
|
self.state.mainWindows[uuid]?.viewToBeFocused = nil
|
||||||
self.state.mainWindows[uuid]?.urlsToOpen.removeAll()
|
self.state.mainWindows[uuid]?.urlsToOpen.removeAll()
|
||||||
|
@ -67,6 +67,14 @@ extension MainWindow {
|
|||||||
self.emit(self.uuidAction(for: .cd(to: self.neoVimView.cwd)))
|
self.emit(self.uuidAction(for: .cd(to: self.neoVimView.cwd)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func tcwdChanged() {
|
||||||
|
self.emit(self.uuidAction(for: .tcd(to: self.neoVimView.cwd)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func lcwdChanged() {
|
||||||
|
self.emit(self.uuidAction(for: .lcd(to: self.neoVimView.cwd)))
|
||||||
|
}
|
||||||
|
|
||||||
func bufferListChanged() {
|
func bufferListChanged() {
|
||||||
self.neoVimView
|
self.neoVimView
|
||||||
.allBuffers()
|
.allBuffers()
|
||||||
|
@ -10,6 +10,8 @@ import Workspace
|
|||||||
extension MainWindow {
|
extension MainWindow {
|
||||||
enum Action {
|
enum Action {
|
||||||
case cd(to: URL)
|
case cd(to: URL)
|
||||||
|
case tcd(to: URL)
|
||||||
|
case lcd(to: URL)
|
||||||
case setBufferList([NvimView.Buffer])
|
case setBufferList([NvimView.Buffer])
|
||||||
|
|
||||||
case newCurrentBuffer(NvimView.Buffer)
|
case newCurrentBuffer(NvimView.Buffer)
|
||||||
|
@ -290,6 +290,10 @@ final class MainWindow: NSObject,
|
|||||||
|
|
||||||
case .cwdChanged: self?.cwdChanged()
|
case .cwdChanged: self?.cwdChanged()
|
||||||
|
|
||||||
|
case .tcwdChanged: self?.tcwdChanged()
|
||||||
|
|
||||||
|
case .lcwdChanged: self?.lcwdChanged()
|
||||||
|
|
||||||
case .bufferListChanged: self?.bufferListChanged()
|
case .bufferListChanged: self?.bufferListChanged()
|
||||||
|
|
||||||
case .tabChanged: self?.tabChanged()
|
case .tabChanged: self?.tabChanged()
|
||||||
@ -348,6 +352,16 @@ final class MainWindow: NSObject,
|
|||||||
self.neoVimView.tabBar?.cwd = cwd.path
|
self.neoVimView.tabBar?.cwd = cwd.path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let cwd = state.tcwdToSet {
|
||||||
|
self.neoVimView.tcwd = cwd
|
||||||
|
self.neoVimView.tabBar?.cwd = cwd.path
|
||||||
|
}
|
||||||
|
|
||||||
|
if let cwd = state.lcwdToSet {
|
||||||
|
self.neoVimView.lcwd = cwd
|
||||||
|
self.neoVimView.tabBar?.cwd = cwd.path
|
||||||
|
}
|
||||||
|
|
||||||
Completable
|
Completable
|
||||||
.empty()
|
.empty()
|
||||||
.andThen {
|
.andThen {
|
||||||
|
@ -22,6 +22,18 @@ final class MainWindowReducer: ReducerType {
|
|||||||
state.cwdToSet = cwd // Ensure updates also pend to tab bar
|
state.cwdToSet = cwd // Ensure updates also pend to tab bar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case let .tcd(to: cwd):
|
||||||
|
if state.cwd != cwd {
|
||||||
|
state.cwd = cwd
|
||||||
|
state.tcwdToSet = cwd // Ensure updates also pend to tab bar
|
||||||
|
}
|
||||||
|
|
||||||
|
case let .lcd(to: cwd):
|
||||||
|
if state.cwd != cwd {
|
||||||
|
state.cwd = cwd
|
||||||
|
state.lcwdToSet = cwd // Ensure updates also pend to tab bar
|
||||||
|
}
|
||||||
|
|
||||||
case let .setBufferList(buffers):
|
case let .setBufferList(buffers):
|
||||||
state.buffers = buffers
|
state.buffers = buffers
|
||||||
|
|
||||||
|
@ -335,6 +335,8 @@ extension MainWindow {
|
|||||||
var urlsToOpen = [URL: OpenMode]()
|
var urlsToOpen = [URL: OpenMode]()
|
||||||
var currentBufferToSet: NvimView.Buffer?
|
var currentBufferToSet: NvimView.Buffer?
|
||||||
var cwdToSet: URL?
|
var cwdToSet: URL?
|
||||||
|
var tcwdToSet: URL?
|
||||||
|
var lcwdToSet: URL?
|
||||||
var viewToBeFocused: FocusableView? = FocusableView.neoVimView
|
var viewToBeFocused: FocusableView? = FocusableView.neoVimView
|
||||||
|
|
||||||
init(isAllToolsVisible: Bool, isToolButtonsVisible: Bool, nvimBinary: String) {
|
init(isAllToolsVisible: Bool, isToolButtonsVisible: Bool, nvimBinary: String) {
|
||||||
|
Loading…
Reference in New Issue
Block a user