mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-26 23:36:08 +03:00
GH-264 Add path control
This commit is contained in:
parent
e5e40dfd04
commit
b47f6caf8d
@ -24,6 +24,16 @@ class MainWindowComponent: WindowComponent, NSWindowDelegate, NeoVimViewDelegate
|
||||
return self.neoVimView.uuid
|
||||
}
|
||||
|
||||
var cwd: NSURL {
|
||||
get {
|
||||
return self.neoVimView.cwd
|
||||
}
|
||||
|
||||
set {
|
||||
self.neoVimView.cwd = newValue
|
||||
}
|
||||
}
|
||||
|
||||
private let neoVimView = NeoVimView(forAutoLayout: ())
|
||||
|
||||
init(source: Observable<Any>, urls: [NSURL] = [], initialData: PrefData) {
|
||||
@ -47,10 +57,6 @@ class MainWindowComponent: WindowComponent, NSWindowDelegate, NeoVimViewDelegate
|
||||
self.neoVimView.open(urls: urls)
|
||||
}
|
||||
|
||||
func set(cwd cwd: NSURL) {
|
||||
self.neoVimView.cwd = cwd
|
||||
}
|
||||
|
||||
func isDirty() -> Bool {
|
||||
return self.neoVimView.hasDirtyDocs()
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class MainWindowService: StandardFlow {
|
||||
let mainWindowComponent = MainWindowComponent(
|
||||
source: self.source, urls: urls, initialData: self.data
|
||||
)
|
||||
mainWindowComponent.set(cwd: cwd)
|
||||
mainWindowComponent.cwd = cwd
|
||||
self.mainWindowComponents[mainWindowComponent.uuid] = mainWindowComponent
|
||||
|
||||
mainWindowComponent.sink
|
||||
@ -77,7 +77,7 @@ class MainWindowService: StandardFlow {
|
||||
return
|
||||
}
|
||||
|
||||
keyMainWindow.set(cwd: cwd)
|
||||
keyMainWindow.cwd = cwd
|
||||
keyMainWindow.open(urls: urls)
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import RxSwift
|
||||
class OpenQuicklyWindowComponent: WindowComponent, NSWindowDelegate, NSTableViewDelegate, NSTableViewDataSource {
|
||||
|
||||
private let searchField = NSTextField(forAutoLayout: ())
|
||||
private let cwdControl = NSPathControl(forAutoLayout: ())
|
||||
|
||||
init(source: Observable<Any>) {
|
||||
super.init(source: source, nibName: "OpenQuicklyWindow")
|
||||
@ -18,18 +19,36 @@ class OpenQuicklyWindowComponent: WindowComponent, NSWindowDelegate, NSTableView
|
||||
}
|
||||
|
||||
override func addViews() {
|
||||
self.window.contentView?.addSubview(searchField)
|
||||
self.searchField.autoPinEdgesToSuperviewEdgesWithInsets(NSEdgeInsets(top: 18, left: 18, bottom: 18, right: 18))
|
||||
let cwdControl = self.cwdControl
|
||||
cwdControl.pathStyle = .Standard
|
||||
cwdControl.backgroundColor = NSColor.clearColor()
|
||||
cwdControl.refusesFirstResponder = true
|
||||
cwdControl.cell?.controlSize = .SmallControlSize
|
||||
cwdControl.cell?.font = NSFont.systemFontOfSize(NSFont.smallSystemFontSize())
|
||||
cwdControl.setContentCompressionResistancePriority(NSLayoutPriorityDefaultLow, forOrientation:.Horizontal)
|
||||
|
||||
self.searchField.becomeFirstResponder()
|
||||
let searchField = self.searchField
|
||||
|
||||
self.window.contentView?.addSubview(searchField)
|
||||
self.window.contentView?.addSubview(cwdControl)
|
||||
|
||||
searchField.autoPinEdgeToSuperviewEdge(.Top, withInset: 18)
|
||||
searchField.autoPinEdgeToSuperviewEdge(.Right, withInset: 18)
|
||||
searchField.autoPinEdgeToSuperviewEdge(.Left, withInset: 18)
|
||||
|
||||
cwdControl.autoPinEdge(.Top, toEdge: .Bottom, ofView: searchField, withOffset: 18)
|
||||
cwdControl.autoPinEdge(.Right, toEdge: .Right, ofView: searchField)
|
||||
cwdControl.autoPinEdge(.Left, toEdge: .Left, ofView: searchField)
|
||||
cwdControl.autoPinEdgeToSuperviewEdge(.Bottom, withInset: 18)
|
||||
}
|
||||
|
||||
override func subscription(source source: Observable<Any>) -> Disposable {
|
||||
return NopDisposable.instance
|
||||
}
|
||||
|
||||
override func show() {
|
||||
super.show()
|
||||
func show(forMainWindow mainWindow: MainWindowComponent) {
|
||||
self.cwdControl.URL = mainWindow.cwd
|
||||
self.show()
|
||||
|
||||
self.searchField.becomeFirstResponder()
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class OpenQuicklyWindowService: StandardFlow {
|
||||
}
|
||||
|
||||
func open(forMainWindow mainWindow: MainWindowComponent) {
|
||||
self.openQuicklyWindow.show()
|
||||
self.openQuicklyWindow.show(forMainWindow: mainWindow)
|
||||
}
|
||||
|
||||
override func subscription(source source: Observable<Any>) -> Disposable {
|
||||
|
Loading…
Reference in New Issue
Block a user