1
1
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:
Tae Won Ha 2016-11-13 22:35:05 +01:00
parent 54a0e4ec01
commit 22732e3fcc
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
3 changed files with 22 additions and 3 deletions

View File

@ -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)
}

View File

@ -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

View File

@ -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])
}
}