mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-28 11:35:35 +03:00
GH-296 Add uuid to tools to use it as pasteboard data
This commit is contained in:
parent
54a0e4ec01
commit
22732e3fcc
@ -43,6 +43,7 @@ class Workspace: NSView, WorkspaceBarDelegate {
|
|||||||
// MARK: - API
|
// MARK: - API
|
||||||
let mainView: NSView
|
let mainView: NSView
|
||||||
let bars: [WorkspaceBarLocation: WorkspaceBar]
|
let bars: [WorkspaceBarLocation: WorkspaceBar]
|
||||||
|
var tools = [WorkspaceTool]()
|
||||||
let config: Config
|
let config: Config
|
||||||
|
|
||||||
weak var delegate: WorkspaceDelegate?
|
weak var delegate: WorkspaceDelegate?
|
||||||
@ -67,6 +68,11 @@ class Workspace: NSView, WorkspaceBarDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func append(tool: WorkspaceTool, location: WorkspaceBarLocation) {
|
func append(tool: WorkspaceTool, location: WorkspaceBarLocation) {
|
||||||
|
if self.tools.contains(tool) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
self.tools.append(tool)
|
||||||
self.bars[location]?.append(tool: tool)
|
self.bars[location]?.append(tool: tool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,9 +10,14 @@ protocol WorkspaceToolDelegate: class {
|
|||||||
func toggle(_ tool: WorkspaceTool)
|
func toggle(_ tool: WorkspaceTool)
|
||||||
}
|
}
|
||||||
|
|
||||||
class WorkspaceTool {
|
class WorkspaceTool: Equatable {
|
||||||
|
|
||||||
|
static func ==(left: WorkspaceTool, right: WorkspaceTool) -> Bool {
|
||||||
|
return left.uuid == right.uuid
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - API
|
// MARK: - API
|
||||||
|
let uuid = UUID().uuidString
|
||||||
let title: String
|
let title: String
|
||||||
let view: NSView
|
let view: NSView
|
||||||
let button: WorkspaceToolButton
|
let button: WorkspaceToolButton
|
||||||
|
@ -145,7 +145,15 @@ extension WorkspaceToolButton {
|
|||||||
// MARK: - NSPasteboardItemDataProvider
|
// MARK: - NSPasteboardItemDataProvider
|
||||||
extension WorkspaceToolButton {
|
extension WorkspaceToolButton {
|
||||||
|
|
||||||
func pasteboard(_ pasteboard: NSPasteboard?, item: NSPasteboardItem, provideDataForType type: String) {
|
func pasteboard(_ pasteboardOptional: NSPasteboard?, item: NSPasteboardItem, provideDataForType type: String) {
|
||||||
// FIXME
|
guard let pasteboard = pasteboardOptional else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
guard type == WorkspaceToolButton.toolUti else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
pasteboard.writeObjects([self.tool!.uuid as NSString])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user