diff --git a/VimR/MainWindowComponent.swift b/VimR/MainWindowComponent.swift index e7d98c43..be0985b1 100644 --- a/VimR/MainWindowComponent.swift +++ b/VimR/MainWindowComponent.swift @@ -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, urls: [NSURL] = [], initialData: PrefData) { @@ -46,10 +56,6 @@ class MainWindowComponent: WindowComponent, NSWindowDelegate, NeoVimViewDelegate func open(urls urls: [NSURL]) { self.neoVimView.open(urls: urls) } - - func set(cwd cwd: NSURL) { - self.neoVimView.cwd = cwd - } func isDirty() -> Bool { return self.neoVimView.hasDirtyDocs() diff --git a/VimR/MainWindowService.swift b/VimR/MainWindowService.swift index c1887510..77f82fae 100644 --- a/VimR/MainWindowService.swift +++ b/VimR/MainWindowService.swift @@ -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) } diff --git a/VimR/OpenQuicklyWindowComponent.swift b/VimR/OpenQuicklyWindowComponent.swift index 10efc0e4..75d88d0d 100644 --- a/VimR/OpenQuicklyWindowComponent.swift +++ b/VimR/OpenQuicklyWindowComponent.swift @@ -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) { 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) -> Disposable { return NopDisposable.instance } - override func show() { - super.show() + func show(forMainWindow mainWindow: MainWindowComponent) { + self.cwdControl.URL = mainWindow.cwd + self.show() self.searchField.becomeFirstResponder() } diff --git a/VimR/OpenQuicklyWindowService.swift b/VimR/OpenQuicklyWindowService.swift index 823c7e82..28a95491 100644 --- a/VimR/OpenQuicklyWindowService.swift +++ b/VimR/OpenQuicklyWindowService.swift @@ -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) -> Disposable {