mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-24 11:37:32 +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
|
||||
let mainView: NSView
|
||||
let bars: [WorkspaceBarLocation: WorkspaceBar]
|
||||
var tools = [WorkspaceTool]()
|
||||
let config: Config
|
||||
|
||||
weak var delegate: WorkspaceDelegate?
|
||||
@ -67,6 +68,11 @@ class Workspace: NSView, WorkspaceBarDelegate {
|
||||
}
|
||||
|
||||
func append(tool: WorkspaceTool, location: WorkspaceBarLocation) {
|
||||
if self.tools.contains(tool) {
|
||||
return
|
||||
}
|
||||
|
||||
self.tools.append(tool)
|
||||
self.bars[location]?.append(tool: tool)
|
||||
}
|
||||
|
||||
|
@ -10,9 +10,14 @@ protocol WorkspaceToolDelegate: class {
|
||||
func toggle(_ tool: WorkspaceTool)
|
||||
}
|
||||
|
||||
class WorkspaceTool {
|
||||
class WorkspaceTool: Equatable {
|
||||
|
||||
static func ==(left: WorkspaceTool, right: WorkspaceTool) -> Bool {
|
||||
return left.uuid == right.uuid
|
||||
}
|
||||
|
||||
// MARK: - API
|
||||
let uuid = UUID().uuidString
|
||||
let title: String
|
||||
let view: NSView
|
||||
let button: WorkspaceToolButton
|
||||
|
@ -145,7 +145,15 @@ extension WorkspaceToolButton {
|
||||
// MARK: - NSPasteboardItemDataProvider
|
||||
extension WorkspaceToolButton {
|
||||
|
||||
func pasteboard(_ pasteboard: NSPasteboard?, item: NSPasteboardItem, provideDataForType type: String) {
|
||||
// FIXME
|
||||
func pasteboard(_ pasteboardOptional: NSPasteboard?, item: NSPasteboardItem, provideDataForType type: String) {
|
||||
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