Skip to content

Commit

Permalink
Allow to add additional separator after "Clear" item
Browse files Browse the repository at this point in the history
Closes #45
  • Loading branch information
p0deje committed Sep 11, 2019
1 parent 448fe5e commit 4d4af25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Maccy/Maccy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Maccy {

private let showInStatusBar = "showInStatusBar"
private let pasteByDefault = "pasteByDefault"
private let saratovSeparator = "enableSaratovSeparator"

private let history: History
private let clipboard: Clipboard
Expand All @@ -28,7 +29,7 @@ class Maccy {
self.clipboard = clipboard
menu.history = history

UserDefaults.standard.register(defaults: [showInStatusBar: true, pasteByDefault: false])
UserDefaults.standard.register(defaults: [showInStatusBar: true, pasteByDefault: false, saratovSeparator: false])
}

func start() {
Expand Down Expand Up @@ -74,6 +75,9 @@ class Maccy {
private func populateFooter() {
menu.addItem(NSMenuItem.separator())
menu.addItem(clearItem)
if UserDefaults.standard.bool(forKey: saratovSeparator) {
menu.addItem(NSMenuItem.separator())
}
menu.addItem(aboutItem)
menu.addItem(NSMenuItem(title: "Quit", action: #selector(NSApp.stop), keyEquivalent: "q"))
}
Expand Down
2 changes: 1 addition & 1 deletion Maccy/Menu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class Menu: NSMenu, NSMenuDelegate {
}

private func isSystemItem(item: NSMenuItem) -> Bool {
let items = allItems.split(whereSeparator: { $0.isSeparatorItem })
let items = allItems.split(maxSplits: 1, omittingEmptySubsequences: true, whereSeparator: { $0.isSeparatorItem })
return items.count > 1 && items[1].contains(item)
}
}

0 comments on commit 4d4af25

Please sign in to comment.