mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-01 01:32:04 +03:00
GH-296 Add pref data for tools
This commit is contained in:
parent
2c839446fe
commit
bf1d26c00e
@ -84,6 +84,9 @@
|
|||||||
4B6A70991D65058A00E12030 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B56F29B1D29926600C1F92E /* Nimble.framework */; };
|
4B6A70991D65058A00E12030 /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B56F29B1D29926600C1F92E /* Nimble.framework */; };
|
||||||
4B6A709C1D6507A000E12030 /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B56F29B1D29926600C1F92E /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
4B6A709C1D6507A000E12030 /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4B56F29B1D29926600C1F92E /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
4B6B0A781DA2A1A500212D6D /* FileOutlineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B6B0A771DA2A1A500212D6D /* FileOutlineView.swift */; };
|
4B6B0A781DA2A1A500212D6D /* FileOutlineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B6B0A771DA2A1A500212D6D /* FileOutlineView.swift */; };
|
||||||
|
4B705BA11DDF7639005F844B /* ToolPrefData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B705BA01DDF7639005F844B /* ToolPrefData.swift */; };
|
||||||
|
4B705BA21DDF7736005F844B /* ProxyWorkspaceBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BB409ED1DDA77E9005F39A2 /* ProxyWorkspaceBar.swift */; };
|
||||||
|
4B705BA31DDF7742005F844B /* ToolPrefData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B705BA01DDF7639005F844B /* ToolPrefData.swift */; };
|
||||||
4B854A1D1D31447C00E08DE1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B854A1C1D31447C00E08DE1 /* main.m */; };
|
4B854A1D1D31447C00E08DE1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B854A1C1D31447C00E08DE1 /* main.m */; };
|
||||||
4B8AC0441DBCB3A2007CCC9B /* NeoVimObjectsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8AC0431DBCB3A1007CCC9B /* NeoVimObjectsExtensions.swift */; };
|
4B8AC0441DBCB3A2007CCC9B /* NeoVimObjectsExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B8AC0431DBCB3A1007CCC9B /* NeoVimObjectsExtensions.swift */; };
|
||||||
4B97E2CC1D33F53D00FC0660 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B97E2CE1D33F53D00FC0660 /* MainWindow.xib */; };
|
4B97E2CC1D33F53D00FC0660 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4B97E2CE1D33F53D00FC0660 /* MainWindow.xib */; };
|
||||||
@ -314,6 +317,7 @@
|
|||||||
4B6A70931D60E04200E12030 /* AppKitCommons.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppKitCommons.swift; sourceTree = "<group>"; };
|
4B6A70931D60E04200E12030 /* AppKitCommons.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppKitCommons.swift; sourceTree = "<group>"; };
|
||||||
4B6A70951D6100E300E12030 /* SwiftCommons.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftCommons.swift; sourceTree = "<group>"; };
|
4B6A70951D6100E300E12030 /* SwiftCommons.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftCommons.swift; sourceTree = "<group>"; };
|
||||||
4B6B0A771DA2A1A500212D6D /* FileOutlineView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileOutlineView.swift; sourceTree = "<group>"; };
|
4B6B0A771DA2A1A500212D6D /* FileOutlineView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileOutlineView.swift; sourceTree = "<group>"; };
|
||||||
|
4B705BA01DDF7639005F844B /* ToolPrefData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToolPrefData.swift; sourceTree = "<group>"; };
|
||||||
4B854A1A1D31447C00E08DE1 /* NeoVimServer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = NeoVimServer; sourceTree = BUILT_PRODUCTS_DIR; };
|
4B854A1A1D31447C00E08DE1 /* NeoVimServer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = NeoVimServer; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
4B854A1C1D31447C00E08DE1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
4B854A1C1D31447C00E08DE1 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||||
4B8AC0431DBCB3A1007CCC9B /* NeoVimObjectsExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NeoVimObjectsExtensions.swift; sourceTree = "<group>"; };
|
4B8AC0431DBCB3A1007CCC9B /* NeoVimObjectsExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NeoVimObjectsExtensions.swift; sourceTree = "<group>"; };
|
||||||
@ -562,6 +566,15 @@
|
|||||||
path = "VimR-Workspace-Demo";
|
path = "VimR-Workspace-Demo";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
4B705B9F1DDF761C005F844B /* Tools */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
4B705BA01DDF7639005F844B /* ToolPrefData.swift */,
|
||||||
|
4B0677351D99D9A2001A2588 /* File Browser */,
|
||||||
|
);
|
||||||
|
name = Tools;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
4B854A151D31444800E08DE1 /* resources */ = {
|
4B854A151D31444800E08DE1 /* resources */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -628,7 +641,7 @@
|
|||||||
1929B39DA7AC4A9B62D7CD39 /* Component.swift */,
|
1929B39DA7AC4A9B62D7CD39 /* Component.swift */,
|
||||||
4BD3BF961D32B0DB00082605 /* MainWindowManager.swift */,
|
4BD3BF961D32B0DB00082605 /* MainWindowManager.swift */,
|
||||||
4BD3BF921D32A95800082605 /* MainWindowComponent.swift */,
|
4BD3BF921D32A95800082605 /* MainWindowComponent.swift */,
|
||||||
4B0677351D99D9A2001A2588 /* File Browser */,
|
4B705B9F1DDF761C005F844B /* Tools */,
|
||||||
4B1AC1AF1D7F395300898F0B /* Open Quickly */,
|
4B1AC1AF1D7F395300898F0B /* Open Quickly */,
|
||||||
4B238BED1D3ED55300CBDD98 /* Preferences */,
|
4B238BED1D3ED55300CBDD98 /* Preferences */,
|
||||||
);
|
);
|
||||||
@ -1070,6 +1083,7 @@
|
|||||||
4B6423961D8EFD7100FC78C8 /* Workspace.swift in Sources */,
|
4B6423961D8EFD7100FC78C8 /* Workspace.swift in Sources */,
|
||||||
4B22F7F21D7C6B9000929B0E /* ImageAndTextTableCell.swift in Sources */,
|
4B22F7F21D7C6B9000929B0E /* ImageAndTextTableCell.swift in Sources */,
|
||||||
4BDF50141D7617EA00D8FBC3 /* OpenQuicklyWindowComponent.swift in Sources */,
|
4BDF50141D7617EA00D8FBC3 /* OpenQuicklyWindowComponent.swift in Sources */,
|
||||||
|
4B705BA11DDF7639005F844B /* ToolPrefData.swift in Sources */,
|
||||||
4B6A70941D60E04200E12030 /* AppKitCommons.swift in Sources */,
|
4B6A70941D60E04200E12030 /* AppKitCommons.swift in Sources */,
|
||||||
4BD3BF971D32B0DB00082605 /* MainWindowManager.swift in Sources */,
|
4BD3BF971D32B0DB00082605 /* MainWindowManager.swift in Sources */,
|
||||||
4B238BEC1D3ED54D00CBDD98 /* AppearancePrefPane.swift in Sources */,
|
4B238BEC1D3ED54D00CBDD98 /* AppearancePrefPane.swift in Sources */,
|
||||||
@ -1106,6 +1120,8 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
4B705BA31DDF7742005F844B /* ToolPrefData.swift in Sources */,
|
||||||
|
4B705BA21DDF7736005F844B /* ProxyWorkspaceBar.swift in Sources */,
|
||||||
4B0677401DA170D5001A2588 /* AppKitCommons.swift in Sources */,
|
4B0677401DA170D5001A2588 /* AppKitCommons.swift in Sources */,
|
||||||
4B0677411DA170D5001A2588 /* Workspace.swift in Sources */,
|
4B0677411DA170D5001A2588 /* Workspace.swift in Sources */,
|
||||||
4B0677421DA170D5001A2588 /* WorkspaceBar.swift in Sources */,
|
4B0677421DA170D5001A2588 /* WorkspaceBar.swift in Sources */,
|
||||||
|
@ -162,12 +162,14 @@ class ViewComponent: NSView, Flow {
|
|||||||
|
|
||||||
class WorkspaceToolComponent: WorkspaceTool, Flow {
|
class WorkspaceToolComponent: WorkspaceTool, Flow {
|
||||||
|
|
||||||
|
let toolIdentifier: ToolIdentifier
|
||||||
let viewComponent: ViewComponent
|
let viewComponent: ViewComponent
|
||||||
var sink: Observable<Any> {
|
var sink: Observable<Any> {
|
||||||
return self.viewComponent.sink
|
return self.viewComponent.sink
|
||||||
}
|
}
|
||||||
|
|
||||||
init(title: String, viewComponent: ViewComponent, minimumDimension: CGFloat = 50) {
|
init(title: String, viewComponent: ViewComponent, toolIdentifier: ToolIdentifier, minimumDimension: CGFloat = 50) {
|
||||||
|
self.toolIdentifier = toolIdentifier
|
||||||
self.viewComponent = viewComponent
|
self.viewComponent = viewComponent
|
||||||
super.init(title: title, view: viewComponent, minimumDimension: minimumDimension)
|
super.init(title: title, view: viewComponent, minimumDimension: minimumDimension)
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,14 @@ struct MainWindowPrefData {
|
|||||||
let isAllToolsVisible: Bool
|
let isAllToolsVisible: Bool
|
||||||
let isToolButtonsVisible: Bool
|
let isToolButtonsVisible: Bool
|
||||||
|
|
||||||
|
// FIXME: REMOVE!
|
||||||
let isFileBrowserVisible: Bool
|
let isFileBrowserVisible: Bool
|
||||||
let fileBrowserWidth: Float
|
let fileBrowserWidth: Float
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate enum Tool {
|
enum ToolIdentifier: String {
|
||||||
|
|
||||||
case fileBrowser
|
case fileBrowser = "com.qvacua.vimr.tool.file-browser"
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainWindowComponent: WindowComponent, NSWindowDelegate, NSUserInterfaceValidations, WorkspaceDelegate {
|
class MainWindowComponent: WindowComponent, NSWindowDelegate, NSUserInterfaceValidations, WorkspaceDelegate {
|
||||||
@ -42,7 +43,7 @@ class MainWindowComponent: WindowComponent, NSWindowDelegate, NSUserInterfaceVal
|
|||||||
|
|
||||||
fileprivate let workspace: Workspace
|
fileprivate let workspace: Workspace
|
||||||
fileprivate let neoVimView: NeoVimView
|
fileprivate let neoVimView: NeoVimView
|
||||||
fileprivate var tools = [Tool: WorkspaceToolComponent]()
|
fileprivate var tools = [ToolIdentifier: WorkspaceToolComponent]()
|
||||||
|
|
||||||
// MARK: - API
|
// MARK: - API
|
||||||
var uuid: String {
|
var uuid: String {
|
||||||
@ -97,7 +98,10 @@ class MainWindowComponent: WindowComponent, NSWindowDelegate, NSUserInterfaceVal
|
|||||||
// FIXME: We do not use [self.sink, source].toMergedObservables. If we do so, then self.sink seems to live as long
|
// FIXME: We do not use [self.sink, source].toMergedObservables. If we do so, then self.sink seems to live as long
|
||||||
// as source, i.e. forever. Thus, self (MainWindowComponent) does not get deallocated. Not nice...
|
// as source, i.e. forever. Thus, self (MainWindowComponent) does not get deallocated. Not nice...
|
||||||
let fileBrowser = FileBrowserComponent(source: self.sink, fileItemService: fileItemService)
|
let fileBrowser = FileBrowserComponent(source: self.sink, fileItemService: fileItemService)
|
||||||
let fileBrowserTool = WorkspaceToolComponent(title: "Files", viewComponent: fileBrowser, minimumDimension: 100)
|
let fileBrowserTool = WorkspaceToolComponent(title: "Files",
|
||||||
|
viewComponent: fileBrowser,
|
||||||
|
toolIdentifier: .fileBrowser,
|
||||||
|
minimumDimension: 100)
|
||||||
self.tools[.fileBrowser] = fileBrowserTool
|
self.tools[.fileBrowser] = fileBrowserTool
|
||||||
self.workspace.append(tool: fileBrowserTool, location: .left)
|
self.workspace.append(tool: fileBrowserTool, location: .left)
|
||||||
|
|
||||||
|
48
VimR/ToolPrefData.swift
Normal file
48
VimR/ToolPrefData.swift
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Tae Won Ha - http://taewon.de - @hataewon
|
||||||
|
* See LICENSE
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
protocol StandardPrefData {
|
||||||
|
|
||||||
|
init?(dict: [String: Any])
|
||||||
|
func dict() -> [String: Any]
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ToolPrefData: StandardPrefData {
|
||||||
|
|
||||||
|
fileprivate static let identifier = "identifier"
|
||||||
|
fileprivate static let isVisible = "isVisible"
|
||||||
|
fileprivate static let dimension = "dimension"
|
||||||
|
|
||||||
|
let identifier: ToolIdentifier
|
||||||
|
let isVisible: Bool
|
||||||
|
let dimension: Float
|
||||||
|
|
||||||
|
init(identifier: ToolIdentifier, isVisible: Bool, dimension: Float) {
|
||||||
|
self.identifier = identifier
|
||||||
|
self.isVisible = isVisible
|
||||||
|
self.dimension = dimension
|
||||||
|
}
|
||||||
|
|
||||||
|
func dict() -> [String: Any] {
|
||||||
|
return [
|
||||||
|
ToolPrefData.identifier: self.identifier,
|
||||||
|
ToolPrefData.isVisible: self.isVisible,
|
||||||
|
ToolPrefData.dimension: self.dimension,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
init?(dict: [String: Any]) {
|
||||||
|
guard let identifier = dict[ToolPrefData.identifier] as? ToolIdentifier,
|
||||||
|
let isVisible = dict[ToolPrefData.isVisible] as? Bool,
|
||||||
|
let dimension = dict[ToolPrefData.dimension] as? Float
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
self.init(identifier: identifier, isVisible: isVisible, dimension: dimension)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user