mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-29 00:34:26 +03:00
GH-286 Refactor slightly
This commit is contained in:
parent
1105ec0805
commit
786f87564d
@ -8,10 +8,8 @@ import RxSwift
|
||||
|
||||
class FileBrowserComponent: ViewComponent, NSOutlineViewDataSource, NSOutlineViewDelegate {
|
||||
|
||||
fileprivate static let userHomeUrl = URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true)
|
||||
|
||||
fileprivate var cwd = FileBrowserComponent.userHomeUrl
|
||||
fileprivate var cwdFileItem = FileItem(FileBrowserComponent.userHomeUrl)
|
||||
fileprivate var cwd = FileUtils.userHomeUrl
|
||||
fileprivate var cwdFileItem = FileItem(FileUtils.userHomeUrl)
|
||||
|
||||
fileprivate let fileView = NSOutlineView.standardOutlineView()
|
||||
fileprivate let dumb = [NSAttributedString(string: "A"), NSAttributedString(string: "B")]
|
||||
@ -51,7 +49,7 @@ class FileBrowserComponent: ViewComponent, NSOutlineViewDataSource, NSOutlineVie
|
||||
case let .changeCwd(mainWindow: mainWindow):
|
||||
self.cwd = mainWindow.cwd
|
||||
self.cwdFileItem = self.fileItemService.fileItemWithChildren(for: self.cwd) ??
|
||||
self.fileItemService.fileItemWithChildren(for: FileBrowserComponent.userHomeUrl)!
|
||||
self.fileItemService.fileItemWithChildren(for: FileUtils.userHomeUrl)!
|
||||
NSLog("cwd changed to \(self.cwd) of \(mainWindow.uuid)")
|
||||
self.fileView.reloadData()
|
||||
|
||||
|
@ -20,6 +20,8 @@ class FileUtils {
|
||||
]
|
||||
|
||||
fileprivate static let fileManager = FileManager.default
|
||||
|
||||
static let userHomeUrl = URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true)
|
||||
|
||||
static func directDescendants(_ url: URL) -> [URL] {
|
||||
guard let childUrls = try? self.fileManager.contentsOfDirectory(
|
||||
|
@ -11,8 +11,6 @@ enum MainWindowEvent {
|
||||
}
|
||||
|
||||
class MainWindowManager: StandardFlow {
|
||||
|
||||
static fileprivate let userHomeUrl = URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true)
|
||||
|
||||
fileprivate var mainWindowComponents = [String:MainWindowComponent]()
|
||||
fileprivate weak var keyMainWindow: MainWindowComponent?
|
||||
@ -27,7 +25,7 @@ class MainWindowManager: StandardFlow {
|
||||
super.init(source: source)
|
||||
}
|
||||
|
||||
func newMainWindow(urls: [URL] = [], cwd: URL = MainWindowManager.userHomeUrl) -> MainWindowComponent {
|
||||
func newMainWindow(urls: [URL] = [], cwd: URL = FileUtils.userHomeUrl) -> MainWindowComponent {
|
||||
let mainWindowComponent = MainWindowComponent(
|
||||
source: self.source, fileItemService: self.fileItemService, cwd: cwd, urls: urls, initialData: self.data
|
||||
)
|
||||
@ -72,7 +70,7 @@ class MainWindowManager: StandardFlow {
|
||||
return self.mainWindowComponents.values.reduce(false) { $0 ? true : $1.isDirty() }
|
||||
}
|
||||
|
||||
func openInKeyMainWindow(urls:[URL] = [], cwd: URL = MainWindowManager.userHomeUrl) {
|
||||
func openInKeyMainWindow(urls:[URL] = [], cwd: URL = FileUtils.userHomeUrl) {
|
||||
guard !self.mainWindowComponents.isEmpty else {
|
||||
_ = self.newMainWindow(urls: urls, cwd: cwd)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user