mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-28 11:35:35 +03:00
GH-544 Migrate VimR to Swift 4
This commit is contained in:
parent
4fb0962e04
commit
5656f6765a
@ -1371,11 +1371,11 @@
|
||||
4BEBA5041CFF374B00673FDF = {
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
DevelopmentTeam = H96Q2NKTQH;
|
||||
LastSwiftMigration = 0800;
|
||||
LastSwiftMigration = 0900;
|
||||
};
|
||||
4BEBA5131CFF374B00673FDF = {
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
LastSwiftMigration = 0800;
|
||||
LastSwiftMigration = 0900;
|
||||
};
|
||||
};
|
||||
};
|
||||
@ -2216,6 +2216,8 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.qvacua.VimR;
|
||||
PRODUCT_NAME = VimR;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = VimR/Bridge.h;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@ -2235,6 +2237,8 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.qvacua.VimR;
|
||||
PRODUCT_NAME = VimR;
|
||||
SWIFT_OBJC_BRIDGING_HEADER = VimR/Bridge.h;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@ -2250,6 +2254,8 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.qvacua.VimRTests;
|
||||
PRODUCT_NAME = VimRTests;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@ -2265,6 +2271,8 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.qvacua.VimRTests;
|
||||
PRODUCT_NAME = VimRTests;
|
||||
SWIFT_SWIFT3_OBJC_INFERENCE = On;
|
||||
SWIFT_VERSION = 4.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
@ -121,11 +121,11 @@ class AdvancedPref: PrefPane, UiComponent, NSTextFieldDelegate {
|
||||
// MARK: - Actions
|
||||
extension AdvancedPref {
|
||||
|
||||
func useInteractiveZshAction(_ sender: NSButton) {
|
||||
@objc func useInteractiveZshAction(_ sender: NSButton) {
|
||||
self.emit(.setUseInteractiveZsh(sender.boolState))
|
||||
}
|
||||
|
||||
func useSnapshotUpdateChannelAction(_ sender: NSButton) {
|
||||
@objc func useSnapshotUpdateChannelAction(_ sender: NSButton) {
|
||||
self.emit(.setUseSnapshotUpdate(sender.boolState))
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ extension AppDelegate {
|
||||
return false
|
||||
}
|
||||
|
||||
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplicationTerminateReply {
|
||||
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
|
||||
self.stateContext.savePrefs()
|
||||
|
||||
if self.hasDirtyWindows && self.hasMainWindows {
|
||||
@ -143,7 +143,7 @@ extension AppDelegate {
|
||||
discardAndQuitButton.keyEquivalentModifierMask = .command
|
||||
discardAndQuitButton.keyEquivalent = "d"
|
||||
|
||||
if alert.runModal() == NSAlertSecondButtonReturn {
|
||||
if alert.runModal() == .alertSecondButtonReturn {
|
||||
self.uiRoot.prepareQuit()
|
||||
return .terminateNow
|
||||
}
|
||||
@ -172,7 +172,7 @@ extension AppDelegate {
|
||||
// MARK: - AppleScript
|
||||
extension AppDelegate {
|
||||
|
||||
func handle(getUrlEvent event: NSAppleEventDescriptor, replyEvent: NSAppleEventDescriptor) {
|
||||
@objc func handle(getUrlEvent event: NSAppleEventDescriptor, replyEvent: NSAppleEventDescriptor) {
|
||||
guard let urlString = event.paramDescriptor(forKeyword: UInt32(keyDirectObject))?.stringValue else {
|
||||
return
|
||||
}
|
||||
@ -286,7 +286,7 @@ extension AppDelegate {
|
||||
panel.canChooseDirectories = true
|
||||
panel.allowsMultipleSelection = true
|
||||
panel.begin { result in
|
||||
guard result == NSFileHandlingPanelOKButton else {
|
||||
guard result == .OK else {
|
||||
return
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ fileprivate enum VimRUrlAction: String {
|
||||
|
||||
fileprivate let updater = SUUpdater()
|
||||
|
||||
fileprivate let debugMenuItemIdentifier = "debug-menu-item"
|
||||
fileprivate let debugMenuItemIdentifier = NSUserInterfaceItemIdentifier("debug-menu-item")
|
||||
|
||||
fileprivate let filePrefix = "file="
|
||||
fileprivate let cwdPrefix = "cwd="
|
||||
|
@ -43,7 +43,7 @@ extension NSImage {
|
||||
|
||||
result.lockFocus()
|
||||
color.set()
|
||||
NSRectFillUsingOperation(CGRect(origin: .zero, size: self.size), .sourceAtop)
|
||||
CGRect(origin: .zero, size: self.size).fill(using: .sourceAtop)
|
||||
result.unlockFocus()
|
||||
|
||||
return result
|
||||
@ -54,11 +54,11 @@ extension NSButton {
|
||||
|
||||
var boolState: Bool {
|
||||
get {
|
||||
return self.state == NSOnState ? true : false
|
||||
return self.state == .on ? true : false
|
||||
}
|
||||
|
||||
set {
|
||||
self.state = newValue ? NSOnState : NSOffState
|
||||
self.state = newValue ? .on : .off
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -67,11 +67,11 @@ extension NSMenuItem {
|
||||
|
||||
var boolState: Bool {
|
||||
get {
|
||||
return self.state == NSOnState ? true : false
|
||||
return self.state == .on ? true : false
|
||||
}
|
||||
|
||||
set {
|
||||
self.state = newValue ? NSOnState : NSOffState
|
||||
self.state = newValue ? .on : .off
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -102,17 +102,17 @@ extension NSAttributedString {
|
||||
}
|
||||
|
||||
static func infoLabel(markdown: String) -> NSAttributedString {
|
||||
let size = NSFont.smallSystemFontSize()
|
||||
let size = NSFont.smallSystemFontSize
|
||||
let document = CMDocument(data: markdown.data(using: .utf8), options: .normalize)
|
||||
|
||||
let attrs = CMTextAttributes()
|
||||
attrs?.textAttributes = [
|
||||
NSFontAttributeName: NSFont.systemFont(ofSize: size),
|
||||
NSForegroundColorAttributeName: NSColor.gray,
|
||||
NSAttributedStringKey.font: NSFont.systemFont(ofSize: size),
|
||||
NSAttributedStringKey.foregroundColor: NSColor.gray,
|
||||
]
|
||||
attrs?.inlineCodeAttributes = [
|
||||
NSFontAttributeName: NSFont.userFixedPitchFont(ofSize: size)!,
|
||||
NSForegroundColorAttributeName: NSColor.gray,
|
||||
NSAttributedStringKey.font: NSFont.userFixedPitchFont(ofSize: size)!,
|
||||
NSAttributedStringKey.foregroundColor: NSColor.gray,
|
||||
]
|
||||
|
||||
let renderer = CMAttributedStringRenderer(document: document, attributes: attrs)
|
||||
@ -138,7 +138,7 @@ extension NSView {
|
||||
self.removeConstraints(self.constraints)
|
||||
}
|
||||
|
||||
var isFirstResponder: Bool {
|
||||
@objc var isFirstResponder: Bool {
|
||||
return self.window?.firstResponder == self
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ extension NSTableView {
|
||||
static func standardTableView() -> NSTableView {
|
||||
let tableView = NSTableView(frame: CGRect.zero)
|
||||
|
||||
let column = NSTableColumn(identifier: "name")
|
||||
let column = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("name"))
|
||||
column.isEditable = false
|
||||
|
||||
tableView.addTableColumn(column)
|
||||
@ -183,7 +183,7 @@ extension NSOutlineView {
|
||||
}
|
||||
|
||||
static func configure(toStandard outlineView: NSOutlineView) {
|
||||
let column = NSTableColumn(identifier: "name")
|
||||
let column = NSTableColumn(identifier: NSUserInterfaceItemIdentifier("name"))
|
||||
column.resizingMask = .autoresizingMask
|
||||
column.isEditable = false
|
||||
|
||||
|
@ -74,8 +74,6 @@ class AppearancePref: PrefPane, NSComboBoxDelegate, NSControlTextEditingDelegate
|
||||
fileprivate let emit: (Action) -> Void
|
||||
fileprivate let disposeBag = DisposeBag()
|
||||
|
||||
fileprivate let fontManager = NSFontManager.shared()
|
||||
|
||||
fileprivate var font: NSFont
|
||||
fileprivate var linespacing: CGFloat
|
||||
fileprivate var usesLigatures: Bool
|
||||
@ -135,7 +133,7 @@ class AppearancePref: PrefPane, NSComboBoxDelegate, NSControlTextEditingDelegate
|
||||
|
||||
// This takes approx. 0.8s - 1s on my machine... -_-
|
||||
DispatchQueue.global(qos: .background).async {
|
||||
fontPopup.addItems(withTitles: self.fontManager.availableFontNames(with: .fixedPitchFontMask)!)
|
||||
fontPopup.addItems(withTitles: sharedFontManager.availableFontNames(with: .fixedPitchFontMask)!)
|
||||
self.updateViews()
|
||||
}
|
||||
|
||||
@ -162,8 +160,9 @@ class AppearancePref: PrefPane, NSComboBoxDelegate, NSControlTextEditingDelegate
|
||||
previewArea.isHorizontallyResizable = true
|
||||
previewArea.textContainer?.heightTracksTextView = false
|
||||
previewArea.textContainer?.widthTracksTextView = false
|
||||
previewArea.autoresizingMask = [.viewWidthSizable, .viewHeightSizable]
|
||||
previewArea.textContainer?.containerSize = CGSize.init(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)
|
||||
previewArea.autoresizingMask = [.width, .height]
|
||||
previewArea.textContainer?.containerSize = CGSize(width: CGFloat.greatestFiniteMagnitude,
|
||||
height: CGFloat.greatestFiniteMagnitude)
|
||||
previewArea.layoutManager?.replaceTextStorage(NSTextStorage(string: self.exampleText))
|
||||
previewArea.isRichText = false
|
||||
previewArea.turnOffLigatures(self)
|
||||
@ -223,7 +222,7 @@ class AppearancePref: PrefPane, NSComboBoxDelegate, NSControlTextEditingDelegate
|
||||
linespacingField.autoPinEdge(.top, to: .bottom, of: sizeCombo, withOffset: 18)
|
||||
linespacingField.autoPinEdge(.left, to: .right, of: linespacingTitle, withOffset: 5)
|
||||
linespacingField.autoSetDimension(.width, toSize: 60)
|
||||
NotificationCenter.default.addObserver(forName: NSNotification.Name.NSControlTextDidEndEditing,
|
||||
NotificationCenter.default.addObserver(forName: NSControl.textDidEndEditingNotification,
|
||||
object: linespacingField,
|
||||
queue: nil) { [unowned self] _ in
|
||||
self.linespacingAction()
|
||||
@ -259,19 +258,19 @@ class AppearancePref: PrefPane, NSComboBoxDelegate, NSControlTextEditingDelegate
|
||||
// MARK: - Actions
|
||||
extension AppearancePref {
|
||||
|
||||
func usesColorschemeAction(_ sender: NSButton) {
|
||||
@objc func usesColorschemeAction(_ sender: NSButton) {
|
||||
self.emit(.setUsesColorscheme(sender.boolState))
|
||||
}
|
||||
|
||||
func fileIconAction(_ sender: NSButton) {
|
||||
@objc func fileIconAction(_ sender: NSButton) {
|
||||
self.emit(.setShowsFileIcon(sender.boolState))
|
||||
}
|
||||
|
||||
func usesLigaturesAction(_ sender: NSButton) {
|
||||
@objc func usesLigaturesAction(_ sender: NSButton) {
|
||||
self.emit(.setUsesLigatures(sender.boolState))
|
||||
}
|
||||
|
||||
func fontPopupAction(_ sender: NSPopUpButton) {
|
||||
@objc func fontPopupAction(_ sender: NSPopUpButton) {
|
||||
guard let selectedItem = self.fontPopup.selectedItem else {
|
||||
return
|
||||
}
|
||||
@ -293,14 +292,14 @@ extension AppearancePref {
|
||||
}
|
||||
|
||||
let newFontSize = self.cappedFontSize(Int(self.sizes[self.sizeCombo.indexOfSelectedItem]))
|
||||
let newFont = self.fontManager.convert(self.font, toSize: newFontSize)
|
||||
let newFont = sharedFontManager.convert(self.font, toSize: newFontSize)
|
||||
|
||||
self.emit(.setFont(newFont))
|
||||
}
|
||||
|
||||
func sizeComboBoxDidEnter(_ sender: AnyObject!) {
|
||||
@objc func sizeComboBoxDidEnter(_ sender: AnyObject!) {
|
||||
let newFontSize = self.cappedFontSize(self.sizeCombo.integerValue)
|
||||
let newFont = self.fontManager.convert(self.font, toSize: newFontSize)
|
||||
let newFont = sharedFontManager.convert(self.font, toSize: newFontSize)
|
||||
|
||||
self.emit(.setFont(newFont))
|
||||
}
|
||||
@ -338,3 +337,5 @@ extension AppearancePref {
|
||||
return cgfSize
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let sharedFontManager = NSFontManager.shared
|
||||
|
@ -22,7 +22,7 @@ class Application: NSApplication {
|
||||
}
|
||||
|
||||
@IBAction override func showHelp(_: Any?) {
|
||||
NSWorkspace.shared().open(URL(string: "https://github.com/qvacua/vimr/wiki")!)
|
||||
NSWorkspace.shared.open(URL(string: "https://github.com/qvacua/vimr/wiki")!)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ extension FileBrowser {
|
||||
// MARK: - Actions
|
||||
extension FileBrowser {
|
||||
|
||||
func showHiddenAction(_ sender: Any?) {
|
||||
@objc func showHiddenAction(_ sender: Any?) {
|
||||
guard let menuItem = sender as? NSMenuItem else {
|
||||
return
|
||||
}
|
||||
@ -172,11 +172,11 @@ extension FileBrowser {
|
||||
self.emit(UuidAction(uuid: self.uuid, action: .setShowHidden(!menuItem.boolState)))
|
||||
}
|
||||
|
||||
func goToParentAction(_ sender: Any?) {
|
||||
@objc func goToParentAction(_ sender: Any?) {
|
||||
self.emit(UuidAction(uuid: self.uuid, action: .setAsWorkingDirectory(self.cwd.parent)))
|
||||
}
|
||||
|
||||
func scrollToSourceAction(_ sender: Any?) {
|
||||
@objc func scrollToSourceAction(_ sender: Any?) {
|
||||
guard let url = self.currentBufferUrl else {
|
||||
return
|
||||
}
|
||||
@ -184,7 +184,7 @@ extension FileBrowser {
|
||||
self.fileView.select(url)
|
||||
}
|
||||
|
||||
func refreshAction(_ sender: Any?) {
|
||||
@objc func refreshAction(_ sender: Any?) {
|
||||
self.emit(UuidAction(uuid: self.uuid, action: .refresh))
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class FileOutlineView: NSOutlineView,
|
||||
self.delegate = self
|
||||
self.allowsEmptySelection = true
|
||||
|
||||
guard Bundle.main.loadNibNamed("FileBrowserMenu", owner: self, topLevelObjects: nil) else {
|
||||
guard Bundle.main.loadNibNamed(NSNib.Name(rawValue: "FileBrowserMenu"), owner: self, topLevelObjects: nil) else {
|
||||
NSLog("WARN: FileBrowserMenu.xib could not be loaded")
|
||||
return
|
||||
}
|
||||
@ -341,7 +341,7 @@ extension FileOutlineView {
|
||||
extension FileOutlineView {
|
||||
|
||||
func outlineView(_ outlineView: NSOutlineView, rowViewForItem item: Any) -> NSTableRowView? {
|
||||
return self.make(withIdentifier: "file-row-view", owner: self) as? ThemedTableRow
|
||||
return self.makeView(withIdentifier: NSUserInterfaceItemIdentifier("file-row-view"), owner: self) as? ThemedTableRow
|
||||
?? ThemedTableRow(withIdentifier: "file-row-view", themedView: self)
|
||||
}
|
||||
|
||||
@ -350,7 +350,7 @@ extension FileOutlineView {
|
||||
return nil
|
||||
}
|
||||
|
||||
let cell = (self.make(withIdentifier: "file-cell-view", owner: self) as? ThemedTableCell)?.reset()
|
||||
let cell = (self.makeView(withIdentifier: NSUserInterfaceItemIdentifier("file-cell-view"), owner: self) as? ThemedTableCell)?.reset()
|
||||
?? ThemedTableCell(withIdentifier: "file-cell-view")
|
||||
|
||||
cell.isDir = fileBrowserItem.isDir
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
import Cocoa
|
||||
|
||||
fileprivate let workspace = NSWorkspace.shared()
|
||||
fileprivate let workspace = NSWorkspace.shared
|
||||
fileprivate let iconsCache = NSCache<NSURL, NSImage>()
|
||||
|
||||
class FileUtils {
|
||||
|
@ -112,7 +112,7 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
|
||||
|
||||
let ignoreListTitle = self.titleTextField(title: "Files To Ignore:")
|
||||
let ignoreField = self.ignoreField
|
||||
NotificationCenter.default.addObserver(forName: NSNotification.Name.NSControlTextDidEndEditing,
|
||||
NotificationCenter.default.addObserver(forName: NSControl.textDidEndEditingNotification,
|
||||
object: ignoreField,
|
||||
queue: nil) { [unowned self] _ in
|
||||
self.ignorePatternsAction()
|
||||
@ -204,13 +204,13 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
|
||||
// MARK: - Actions
|
||||
extension GeneralPref {
|
||||
|
||||
func copyCliTool(_ sender: NSButton) {
|
||||
@objc func copyCliTool(_ sender: NSButton) {
|
||||
let panel = NSOpenPanel()
|
||||
panel.canChooseFiles = false
|
||||
panel.canChooseDirectories = true
|
||||
|
||||
panel.beginSheetModal(for: self.window!) { result in
|
||||
guard result == NSFileHandlingPanelOKButton else {
|
||||
guard result == .OK else {
|
||||
return
|
||||
}
|
||||
|
||||
@ -234,15 +234,15 @@ extension GeneralPref {
|
||||
}
|
||||
}
|
||||
|
||||
func openUntitledWindowWhenLaunchingAction(_ sender: NSButton) {
|
||||
@objc func openUntitledWindowWhenLaunchingAction(_ sender: NSButton) {
|
||||
self.emit(.setOpenOnLaunch(self.openWhenLaunchingCheckbox.boolState))
|
||||
}
|
||||
|
||||
func openUntitledWindowOnReactivationAction(_ sender: NSButton) {
|
||||
@objc func openUntitledWindowOnReactivationAction(_ sender: NSButton) {
|
||||
self.emit(.setOpenOnReactivation(self.openOnReactivationCheckbox.boolState))
|
||||
}
|
||||
|
||||
func afterLastWindowAction(_ sender: NSPopUpButton) {
|
||||
@objc func afterLastWindowAction(_ sender: NSPopUpButton) {
|
||||
let index = sender.indexOfSelectedItem
|
||||
|
||||
guard index >= 0 && index <= 2 else {
|
||||
|
@ -99,12 +99,12 @@ class HtmlPreviewTool: NSView, UiComponent, WKNavigationDelegate {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func selectHtmlFile(sender: Any?) {
|
||||
@objc func selectHtmlFile(sender: Any?) {
|
||||
let panel = NSOpenPanel()
|
||||
panel.canChooseDirectories = false
|
||||
panel.allowsMultipleSelection = false
|
||||
panel.beginSheetModal(for: self.window!) { result in
|
||||
guard result == NSFileHandlingPanelOKButton else {
|
||||
guard result == .OK else {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ class ImageAndTextTableCell: NSTableCellView {
|
||||
static let widthWithoutText = CGFloat(2 + 16 + 4 + 2)
|
||||
|
||||
static func width(with text: String) -> CGFloat {
|
||||
let attrStr = NSAttributedString(string: text, attributes: [NSFontAttributeName: ImageAndTextTableCell.font])
|
||||
let attrStr = NSAttributedString(string: text, attributes: [NSAttributedStringKey.font: ImageAndTextTableCell.font])
|
||||
|
||||
return self.widthWithoutText + attrStr.size().width
|
||||
}
|
||||
@ -30,7 +30,7 @@ class ImageAndTextTableCell: NSTableCellView {
|
||||
height: max(self._textField.intrinsicContentSize.height, 16))
|
||||
}
|
||||
|
||||
override var backgroundStyle: NSBackgroundStyle {
|
||||
override var backgroundStyle: NSView.BackgroundStyle {
|
||||
didSet {
|
||||
let attrStr = NSMutableAttributedString(attributedString: self.attributedText)
|
||||
|
||||
@ -45,10 +45,10 @@ class ImageAndTextTableCell: NSTableCellView {
|
||||
|
||||
switch self.backgroundStyle {
|
||||
case .light:
|
||||
attrStr.addAttribute(NSForegroundColorAttributeName, value: NSColor.black, range: nameRange)
|
||||
attrStr.addAttribute(NSAttributedStringKey.foregroundColor, value: NSColor.black, range: nameRange)
|
||||
|
||||
case .dark:
|
||||
attrStr.addAttribute(NSForegroundColorAttributeName, value: NSColor.white, range: nameRange)
|
||||
attrStr.addAttribute(NSAttributedStringKey.foregroundColor, value: NSColor.white, range: nameRange)
|
||||
|
||||
default:
|
||||
return
|
||||
@ -91,7 +91,7 @@ class ImageAndTextTableCell: NSTableCellView {
|
||||
init(withIdentifier identifier: String) {
|
||||
super.init(frame: CGRect.zero)
|
||||
|
||||
self.identifier = identifier
|
||||
self.identifier = NSUserInterfaceItemIdentifier(identifier)
|
||||
|
||||
self.textField = self._textField
|
||||
self.imageView = self._imageView
|
||||
|
@ -17,7 +17,7 @@ extension MainWindow {
|
||||
panel.canChooseDirectories = true
|
||||
panel.allowsMultipleSelection = true
|
||||
panel.beginSheetModal(for: self.window) { result in
|
||||
guard result == NSFileHandlingPanelOKButton else {
|
||||
guard result == .OK else {
|
||||
return
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ extension MainWindow {
|
||||
fileprivate func savePanelSheet(action: @escaping (URL) -> Void) {
|
||||
let panel = NSSavePanel()
|
||||
panel.beginSheetModal(for: self.window) { result in
|
||||
guard result == NSFileHandlingPanelOKButton else {
|
||||
guard result == .OK else {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ extension MainWindow {
|
||||
}
|
||||
|
||||
func set(repUrl url: URL?, themed: Bool) {
|
||||
if self.window.styleMask.contains(.fullScreen) || themed == false {
|
||||
if self.window.styleMask.contains(NSWindow.StyleMask.fullScreen) || themed == false {
|
||||
self.internalSetRepUrl(url)
|
||||
return
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ extension MainWindow {
|
||||
self.emit(self.uuidAction(for: .frameChanged(to: self.window.frame)))
|
||||
}
|
||||
|
||||
func windowShouldClose(_: Any) -> Bool {
|
||||
func windowShouldClose(_: NSWindow) -> Bool {
|
||||
guard self.neoVimView.isCurrentBufferDirty() else {
|
||||
self.neoVimView.closeCurrentTab()
|
||||
return false
|
||||
@ -146,7 +146,7 @@ extension MainWindow {
|
||||
discardAndCloseButton.keyEquivalentModifierMask = .command
|
||||
discardAndCloseButton.keyEquivalent = "d"
|
||||
alert.beginSheetModal(for: self.window, completionHandler: { response in
|
||||
if response == NSAlertSecondButtonReturn {
|
||||
if response == .alertSecondButtonReturn {
|
||||
self.neoVimView.closeCurrentTabWithoutSaving()
|
||||
}
|
||||
})
|
||||
|
@ -108,7 +108,7 @@ class MainWindow: NSObject,
|
||||
|
||||
self.cliPipePath = state.cliPipePath
|
||||
|
||||
self.windowController = NSWindowController(windowNibName: "MainWindow")
|
||||
self.windowController = NSWindowController(windowNibName: NSNib.Name(rawValue: "MainWindow"))
|
||||
|
||||
let neoVimViewConfig = NeoVimView.Config(useInteractiveZsh: state.useInteractiveZsh,
|
||||
cwd: state.cwd,
|
||||
@ -322,8 +322,6 @@ class MainWindow: NSObject,
|
||||
fileprivate var linespacing = NeoVimView.defaultLinespacing
|
||||
fileprivate var usesLigatures = false
|
||||
|
||||
fileprivate let fontManager = NSFontManager.shared()
|
||||
|
||||
fileprivate var previewPosition = Marked(Position.beginning)
|
||||
|
||||
fileprivate var preview: PreviewTool?
|
||||
|
@ -14,7 +14,7 @@ class OpenQuicklyFileViewRow: NSTableRowView {
|
||||
NSColor.clear.set()
|
||||
}
|
||||
|
||||
self.rectsBeingDrawn().forEach { NSRectFillUsingOperation(NSIntersectionRect($0, dirtyRect), .sourceOver) }
|
||||
self.rectsBeingDrawn().forEach { NSIntersectionRect($0, dirtyRect).fill(using: .sourceOver) }
|
||||
}
|
||||
|
||||
fileprivate func rectsBeingDrawn() -> [CGRect] {
|
||||
|
@ -26,7 +26,7 @@ class OpenQuicklyWindow: NSObject,
|
||||
|
||||
required init(source: Observable<StateType>, emitter: ActionEmitter, state: StateType) {
|
||||
self.emit = emitter.typedEmit()
|
||||
self.windowController = NSWindowController(windowNibName: "OpenQuicklyWindow")
|
||||
self.windowController = NSWindowController(windowNibName: NSNib.Name("OpenQuicklyWindow"))
|
||||
|
||||
self.searchStream = self.searchField.rx
|
||||
.text.orEmpty
|
||||
@ -155,7 +155,7 @@ class OpenQuicklyWindow: NSObject,
|
||||
let progressIndicator = self.progressIndicator
|
||||
progressIndicator.isIndeterminate = true
|
||||
progressIndicator.isDisplayedWhenStopped = false
|
||||
progressIndicator.style = .spinningStyle
|
||||
progressIndicator.style = .spinning
|
||||
progressIndicator.controlSize = .small
|
||||
|
||||
let fileView = self.fileView
|
||||
@ -172,8 +172,8 @@ class OpenQuicklyWindow: NSObject,
|
||||
cwdControl.backgroundColor = NSColor.clear
|
||||
cwdControl.refusesFirstResponder = true
|
||||
cwdControl.cell?.controlSize = .small
|
||||
cwdControl.cell?.font = NSFont.systemFont(ofSize: NSFont.smallSystemFontSize())
|
||||
cwdControl.setContentCompressionResistancePriority(NSLayoutPriorityDefaultLow, for: .horizontal)
|
||||
cwdControl.cell?.font = NSFont.systemFont(ofSize: NSFont.smallSystemFontSize)
|
||||
cwdControl.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
||||
|
||||
let countField = self.countField
|
||||
countField.isEditable = false
|
||||
@ -231,7 +231,7 @@ extension OpenQuicklyWindow {
|
||||
|
||||
@objc(tableView: viewForTableColumn:row:)
|
||||
func tableView(_ tableView: NSTableView, viewFor _: NSTableColumn?, row: Int) -> NSView? {
|
||||
let cachedCell = (tableView.make(withIdentifier: "file-view-row", owner: self) as? ImageAndTextTableCell)?.reset()
|
||||
let cachedCell = (tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier("file-view-row"), owner: self) as? ImageAndTextTableCell)?.reset()
|
||||
let cell = cachedCell ?? ImageAndTextTableCell(withIdentifier: "file-view-row")
|
||||
|
||||
let url = self.fileViewItems[row].url
|
||||
@ -257,7 +257,7 @@ extension OpenQuicklyWindow {
|
||||
let rowText: NSMutableAttributedString
|
||||
let pathInfo = truncatedPathComps.dropLast().reversed().joined(separator: " / ")
|
||||
rowText = NSMutableAttributedString(string: "\(name) — \(pathInfo)")
|
||||
rowText.addAttribute(NSForegroundColorAttributeName,
|
||||
rowText.addAttribute(NSAttributedStringKey.foregroundColor,
|
||||
value: NSColor.lightGray,
|
||||
range: NSRange(location: name.characters.count, length: pathInfo.characters.count + 3))
|
||||
|
||||
@ -315,7 +315,7 @@ extension OpenQuicklyWindow {
|
||||
// MARK: - NSWindowDelegate
|
||||
extension OpenQuicklyWindow {
|
||||
|
||||
func windowShouldClose(_: Any) -> Bool {
|
||||
func windowShouldClose(_: NSWindow) -> Bool {
|
||||
self.emit(.close)
|
||||
|
||||
return false
|
||||
|
@ -114,7 +114,7 @@ class OpenedFileList: NSView,
|
||||
// MARK: - Actions
|
||||
extension OpenedFileList {
|
||||
|
||||
func doubleClickAction(_ sender: Any?) {
|
||||
@objc func doubleClickAction(_ sender: Any?) {
|
||||
let clickedRow = self.bufferList.clickedRow
|
||||
guard clickedRow >= 0 && clickedRow < self.buffers.count else {
|
||||
return
|
||||
@ -137,12 +137,12 @@ extension OpenedFileList {
|
||||
extension OpenedFileList {
|
||||
|
||||
public func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {
|
||||
return tableView.make(withIdentifier: "buffer-row-view", owner: self) as? ThemedTableRow
|
||||
return tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier("buffer-row-view"), owner: self) as? ThemedTableRow
|
||||
?? ThemedTableRow(withIdentifier: "buffer-row-view", themedView: self)
|
||||
}
|
||||
|
||||
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
|
||||
let cachedCell = (tableView.make(withIdentifier: "buffer-cell-view", owner: self) as? ThemedTableCell)?.reset()
|
||||
let cachedCell = (tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier("buffer-cell-view"), owner: self) as? ThemedTableCell)?.reset()
|
||||
let cell = cachedCell ?? ThemedTableCell(withIdentifier: "buffer-cell-view")
|
||||
|
||||
let buffer = self.buffers[row]
|
||||
@ -169,11 +169,11 @@ extension OpenedFileList {
|
||||
let pathInfo = url.pathComponents.dropFirst().dropLast().reversed().joined(separator: " / ") + " /"
|
||||
let rowText = NSMutableAttributedString(string: "\(name) — \(pathInfo)")
|
||||
|
||||
rowText.addAttribute(NSForegroundColorAttributeName,
|
||||
rowText.addAttribute(NSAttributedStringKey.foregroundColor,
|
||||
value: self.theme.foreground,
|
||||
range: NSRange(location: 0, length: name.characters.count))
|
||||
|
||||
rowText.addAttribute(NSForegroundColorAttributeName,
|
||||
rowText.addAttribute(NSAttributedStringKey.foregroundColor,
|
||||
value: self.theme.foreground.brightening(by: 1.15),
|
||||
range: NSRange(location: name.characters.count, length: pathInfo.characters.count + 3))
|
||||
|
||||
|
@ -83,10 +83,10 @@ class PrefUtils {
|
||||
static func saneFont(_ fontName: String, fontSize: CGFloat) -> NSFont {
|
||||
var editorFont = NSFont(name: fontName, size: fontSize) ?? NeoVimView.defaultFont
|
||||
if !editorFont.isFixedPitch {
|
||||
editorFont = NSFontManager.shared().convert(NeoVimView.defaultFont, toSize: editorFont.pointSize)
|
||||
editorFont = NSFontManager.shared.convert(NeoVimView.defaultFont, toSize: editorFont.pointSize)
|
||||
}
|
||||
if editorFont.pointSize < NeoVimView.minFontSize || editorFont.pointSize > NeoVimView.maxFontSize {
|
||||
editorFont = NSFontManager.shared().convert(editorFont, toSize: NeoVimView.defaultFont.pointSize)
|
||||
editorFont = NSFontManager.shared.convert(editorFont, toSize: NeoVimView.defaultFont.pointSize)
|
||||
}
|
||||
|
||||
return editorFont
|
||||
|
@ -23,7 +23,7 @@ class PrefWindow: NSObject,
|
||||
self.emit = emitter.typedEmit()
|
||||
self.openStatusMark = state.preferencesOpen.mark
|
||||
|
||||
self.windowController = NSWindowController(windowNibName: "PrefWindow")
|
||||
self.windowController = NSWindowController(windowNibName: NSNib.Name("PrefWindow"))
|
||||
|
||||
self.panes = [
|
||||
GeneralPref(source: source, emitter: emitter, state: state),
|
||||
@ -122,7 +122,7 @@ class PrefWindow: NSObject,
|
||||
// MARK: - NSWindowDelegate
|
||||
extension PrefWindow {
|
||||
|
||||
func windowShouldClose(_: Any) -> Bool {
|
||||
func windowShouldClose(_: NSWindow) -> Bool {
|
||||
self.emit(.close)
|
||||
|
||||
return false
|
||||
|
@ -178,28 +178,28 @@ class PreviewTool: NSView, UiComponent, WKNavigationDelegate {
|
||||
// MARK: - Actions
|
||||
extension PreviewTool {
|
||||
|
||||
func refreshNowAction(_: Any?) {
|
||||
@objc func refreshNowAction(_: Any?) {
|
||||
self.emit(UuidAction(uuid: self.uuid, action: .refreshNow))
|
||||
}
|
||||
|
||||
func forwardSearchAction(_: Any?) {
|
||||
@objc func forwardSearchAction(_: Any?) {
|
||||
self.forwardSearch(position: self.editorPosition.payload)
|
||||
}
|
||||
|
||||
func reverseSearchAction(_: Any?) {
|
||||
@objc func reverseSearchAction(_: Any?) {
|
||||
self.previewPosition = Marked(self.previewPosition.payload) // set a new mark
|
||||
self.emit(UuidAction(uuid: self.uuid, action: .reverseSearch(to: self.previewPosition)))
|
||||
}
|
||||
|
||||
func automaticForwardSearchAction(_ sender: NSMenuItem) {
|
||||
@objc func automaticForwardSearchAction(_ sender: NSMenuItem) {
|
||||
self.emit(UuidAction(uuid: self.uuid, action: .setAutomaticForwardSearch(to: !sender.boolState)))
|
||||
}
|
||||
|
||||
func automaticReverseSearchAction(_ sender: NSMenuItem) {
|
||||
@objc func automaticReverseSearchAction(_ sender: NSMenuItem) {
|
||||
self.emit(UuidAction(uuid: self.uuid, action: .setAutomaticReverseSearch(to: !sender.boolState)))
|
||||
}
|
||||
|
||||
func refreshOnWriteAction(_ sender: NSMenuItem) {
|
||||
@objc func refreshOnWriteAction(_ sender: NSMenuItem) {
|
||||
self.emit(UuidAction(uuid: self.uuid, action: .setRefreshOnWrite(to: !sender.boolState)))
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ extension String {
|
||||
}
|
||||
|
||||
let idx = self.characters.index(self.startIndex, offsetBy: prefix.characters.count)
|
||||
return self[idx..<self.endIndex]
|
||||
return String(self[idx..<self.endIndex])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ class ThemedTableRow: NSTableRowView {
|
||||
|
||||
super.init(frame: .zero)
|
||||
|
||||
self.identifier = identifier
|
||||
self.identifier = NSUserInterfaceItemIdentifier(identifier)
|
||||
}
|
||||
|
||||
open override func drawBackground(in dirtyRect: NSRect) {
|
||||
@ -32,7 +32,7 @@ class ThemedTableRow: NSTableRowView {
|
||||
}
|
||||
|
||||
self.themedView?.theme.background.set()
|
||||
NSRectFill(dirtyRect)
|
||||
dirtyRect.fill()
|
||||
}
|
||||
|
||||
override func drawSelection(in dirtyRect: NSRect) {
|
||||
@ -41,7 +41,7 @@ class ThemedTableRow: NSTableRowView {
|
||||
}
|
||||
|
||||
self.themedView?.theme.highlightBackground.set()
|
||||
NSRectFill(dirtyRect)
|
||||
dirtyRect.fill()
|
||||
}
|
||||
|
||||
fileprivate weak var themedView: ThemedView?
|
||||
@ -58,7 +58,7 @@ class ThemedTableCell: NSTableCellView {
|
||||
static let widthWithoutText = CGFloat(2 + 16 + 4 + 2)
|
||||
|
||||
static func width(with text: String) -> CGFloat {
|
||||
let attrStr = NSAttributedString(string: text, attributes: [NSFontAttributeName: ThemedTableCell.font])
|
||||
let attrStr = NSAttributedString(string: text, attributes: [NSAttributedStringKey.font: ThemedTableCell.font])
|
||||
|
||||
return self.widthWithoutText + attrStr.size().width
|
||||
}
|
||||
@ -123,7 +123,7 @@ class ThemedTableCell: NSTableCellView {
|
||||
init(withIdentifier identifier: String) {
|
||||
super.init(frame: .zero)
|
||||
|
||||
self.identifier = identifier
|
||||
self.identifier = NSUserInterfaceItemIdentifier(identifier)
|
||||
|
||||
self.textField = self._textField
|
||||
self.imageView = self._imageView
|
||||
@ -154,7 +154,7 @@ class ThemedTableCell: NSTableCellView {
|
||||
textField.removeFromSuperview()
|
||||
self.addSubview(textField)
|
||||
|
||||
textField.autoPinEdgesToSuperviewEdges(with: EdgeInsets(top: 2, left: 4, bottom: 2, right: 2))
|
||||
textField.autoPinEdgesToSuperviewEdges(with: NSEdgeInsets(top: 2, left: 4, bottom: 2, right: 2))
|
||||
}
|
||||
|
||||
fileprivate let _textField = NSTextField(forAutoLayout: ())
|
||||
|
@ -87,7 +87,7 @@ class InnerToolBar: NSView, NSUserInterfaceValidations {
|
||||
|
||||
override var intrinsicContentSize: CGSize {
|
||||
if #available(macOS 10.11, *) {
|
||||
return CGSize(width: NSViewNoIntrinsicMetric, height: InnerToolBar.height)
|
||||
return CGSize(width: NSView.noIntrinsicMetric, height: InnerToolBar.height)
|
||||
} else {
|
||||
return CGSize(width: -1, height: InnerToolBar.height)
|
||||
}
|
||||
@ -128,13 +128,13 @@ class InnerToolBar: NSView, NSUserInterfaceValidations {
|
||||
self.theme.separator.set()
|
||||
let bottomSeparatorRect = self.bottomSeparatorRect()
|
||||
if dirtyRect.intersects(bottomSeparatorRect) {
|
||||
NSRectFill(bottomSeparatorRect)
|
||||
bottomSeparatorRect.fill()
|
||||
}
|
||||
|
||||
self.theme.toolbarForeground.set()
|
||||
let innerSeparatorRect = self.innerSeparatorRect()
|
||||
if dirtyRect.intersects(innerSeparatorRect) {
|
||||
NSRectFill(innerSeparatorRect)
|
||||
innerSeparatorRect.fill()
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,23 +258,23 @@ class InnerToolBar: NSView, NSUserInterfaceValidations {
|
||||
// MARK: - Actions
|
||||
extension InnerToolBar {
|
||||
|
||||
func closeAction(_ sender: Any?) {
|
||||
@objc func closeAction(_ sender: Any?) {
|
||||
self.tool?.toggle()
|
||||
}
|
||||
|
||||
func moveToTopAction(_ sender: Any?) {
|
||||
@objc func moveToTopAction(_ sender: Any?) {
|
||||
self.move(to: .top)
|
||||
}
|
||||
|
||||
func moveToRightAction(_ sender: Any?) {
|
||||
@objc func moveToRightAction(_ sender: Any?) {
|
||||
self.move(to: .right)
|
||||
}
|
||||
|
||||
func moveToBottomAction(_ sender: Any?) {
|
||||
@objc func moveToBottomAction(_ sender: Any?) {
|
||||
self.move(to: .bottom)
|
||||
}
|
||||
|
||||
func moveToLeftAction(_ sender: Any?) {
|
||||
@objc func moveToLeftAction(_ sender: Any?) {
|
||||
self.move(to: .left)
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ class Workspace: NSView, WorkspaceBarDelegate {
|
||||
super.init(frame: .zero)
|
||||
self.configureForAutoLayout()
|
||||
|
||||
self.register(forDraggedTypes: [WorkspaceToolButton.toolUti])
|
||||
self.registerForDraggedTypes([NSPasteboard.PasteboardType(WorkspaceToolButton.toolUti)])
|
||||
self.bars.values.forEach {
|
||||
$0.workspace = self
|
||||
$0.delegate = self
|
||||
@ -161,7 +161,7 @@ extension Workspace {
|
||||
self.endDrag()
|
||||
}
|
||||
|
||||
override func draggingEnded(_ sender: NSDraggingInfo?) {
|
||||
override func draggingEnded(_ sender: NSDraggingInfo) {
|
||||
self.endDrag()
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ extension Workspace {
|
||||
leftBar.autoPinEdge(toSuperviewEdge: .left)
|
||||
leftBar.autoPinEdge(.bottom, to: .top, of: bottomBar)
|
||||
|
||||
NSLayoutConstraint.autoSetPriority(NSLayoutPriorityDragThatCannotResizeWindow) {
|
||||
NSLayoutConstraint.autoSetPriority(.dragThatCannotResizeWindow) {
|
||||
topBar.dimensionConstraint = topBar.autoSetDimension(.height, toSize: 50)
|
||||
rightBar.dimensionConstraint = rightBar.autoSetDimension(.width, toSize: 50)
|
||||
bottomBar.dimensionConstraint = bottomBar.autoSetDimension(.height, toSize: 50)
|
||||
|
@ -38,7 +38,7 @@ fileprivate class ProxyBar: NSView {
|
||||
super.init(frame: .zero)
|
||||
self.configureForAutoLayout()
|
||||
|
||||
self.register(forDraggedTypes: [WorkspaceToolButton.toolUti])
|
||||
self.registerForDraggedTypes([NSPasteboard.PasteboardType(WorkspaceToolButton.toolUti)])
|
||||
|
||||
self.wantsLayer = true
|
||||
}
|
||||
@ -249,7 +249,7 @@ extension ProxyBar {
|
||||
fileprivate func isTool(atIndex idx: Int, beingDragged info: NSDraggingInfo) -> Bool {
|
||||
let pasteboard = info.draggingPasteboard()
|
||||
|
||||
guard let uuid = pasteboard.string(forType: WorkspaceToolButton.toolUti) else {
|
||||
guard let uuid = pasteboard.string(forType: NSPasteboard.PasteboardType(WorkspaceToolButton.toolUti)) else {
|
||||
return false
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ extension ProxyBar {
|
||||
return .move
|
||||
}
|
||||
|
||||
override func draggingEnded(_ sender: NSDraggingInfo?) {
|
||||
override func draggingEnded(_ sender: NSDraggingInfo) {
|
||||
self.endDrag()
|
||||
}
|
||||
|
||||
@ -423,11 +423,11 @@ extension WorkspaceBar {
|
||||
|
||||
self.isMouseDownOngoing = true
|
||||
self.delegate?.resizeWillStart(workspaceBar: self, tool: self.selectedTool)
|
||||
self.dimensionConstraint.priority = NSLayoutPriorityDragThatCannotResizeWindow - 1
|
||||
self.dimensionConstraint.priority = NSLayoutConstraint.Priority(NSLayoutConstraint.Priority.RawValue(Int(NSLayoutConstraint.Priority.dragThatCannotResizeWindow.rawValue) - 1))
|
||||
|
||||
var dragged = false
|
||||
var curEvent = event
|
||||
let nextEventMask: NSEventMask = [.leftMouseDragged, .leftMouseDown, .leftMouseUp]
|
||||
let nextEventMask: NSEvent.EventTypeMask = [.leftMouseDragged, .leftMouseDown, .leftMouseUp]
|
||||
|
||||
while curEvent.type != .leftMouseUp {
|
||||
let nextEvent = NSApp.nextEvent(matching: nextEventMask,
|
||||
@ -459,7 +459,7 @@ extension WorkspaceBar {
|
||||
dragged = true
|
||||
}
|
||||
|
||||
self.dimensionConstraint.priority = NSLayoutPriorityDragThatCannotResizeWindow
|
||||
self.dimensionConstraint.priority = .dragThatCannotResizeWindow
|
||||
self.isMouseDownOngoing = false
|
||||
self.delegate?.resizeDidEnd(workspaceBar: self, tool: self.selectedTool)
|
||||
}
|
||||
@ -471,9 +471,9 @@ extension WorkspaceBar {
|
||||
|
||||
switch self.location {
|
||||
case .top, .bottom:
|
||||
self.addCursorRect(self.resizeRect(), cursor: NSCursor.resizeUpDown())
|
||||
self.addCursorRect(self.resizeRect(), cursor: .resizeUpDown)
|
||||
case .right, .left:
|
||||
self.addCursorRect(self.resizeRect(), cursor: NSCursor.resizeLeftRight())
|
||||
self.addCursorRect(self.resizeRect(), cursor: .resizeLeftRight)
|
||||
}
|
||||
}
|
||||
|
||||
@ -482,7 +482,7 @@ extension WorkspaceBar {
|
||||
|
||||
let innerLineRect = self.innerSeparatorRect()
|
||||
if dirtyRect.intersects(innerLineRect) {
|
||||
NSRectFill(innerLineRect)
|
||||
innerLineRect.fill()
|
||||
}
|
||||
}
|
||||
|
||||
@ -491,7 +491,7 @@ extension WorkspaceBar {
|
||||
|
||||
let outerLineRect = self.outerSeparatorRect()
|
||||
if dirtyRect.intersects(outerLineRect) {
|
||||
NSRectFill(outerLineRect)
|
||||
outerLineRect.fill()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,13 +57,13 @@ class WorkspaceToolButton: NSView, NSDraggingSource {
|
||||
|
||||
init(title: String) {
|
||||
self.title = NSMutableAttributedString(string: title, attributes: [
|
||||
NSFontAttributeName: NSFont.systemFont(ofSize: 11),
|
||||
NSAttributedStringKey.font: NSFont.systemFont(ofSize: 11),
|
||||
])
|
||||
|
||||
super.init(frame: .zero)
|
||||
self.configureForAutoLayout()
|
||||
|
||||
self.title.addAttribute(NSForegroundColorAttributeName,
|
||||
self.title.addAttribute(NSAttributedStringKey.foregroundColor,
|
||||
value: self.theme.foreground,
|
||||
range: NSRange(location: 0, length: self.title.length))
|
||||
|
||||
@ -77,7 +77,7 @@ class WorkspaceToolButton: NSView, NSDraggingSource {
|
||||
self.dehighlight()
|
||||
}
|
||||
|
||||
self.title.addAttribute(NSForegroundColorAttributeName,
|
||||
self.title.addAttribute(NSAttributedStringKey.foregroundColor,
|
||||
value: self.theme.foreground,
|
||||
range: NSRange(location: 0, length: self.title.length))
|
||||
|
||||
@ -137,19 +137,19 @@ extension WorkspaceToolButton {
|
||||
}
|
||||
|
||||
override func mouseDown(with event: NSEvent) {
|
||||
guard let nextEvent = self.window!.nextEvent(matching: [NSLeftMouseUpMask, NSLeftMouseDraggedMask]) else {
|
||||
guard let nextEvent = self.window!.nextEvent(matching: [.leftMouseUp, .leftMouseDragged]) else {
|
||||
return
|
||||
}
|
||||
|
||||
switch nextEvent.type {
|
||||
|
||||
case NSLeftMouseUp:
|
||||
case .leftMouseUp:
|
||||
self.tool?.toggle()
|
||||
return
|
||||
|
||||
case NSLeftMouseDragged:
|
||||
case .leftMouseDragged:
|
||||
let pasteboardItem = NSPasteboardItem()
|
||||
pasteboardItem.setString(self.tool!.uuid, forType: WorkspaceToolButton.toolUti)
|
||||
pasteboardItem.setString(self.tool!.uuid, forType: NSPasteboard.PasteboardType(WorkspaceToolButton.toolUti))
|
||||
|
||||
let draggingItem = NSDraggingItem(pasteboardWriter: pasteboardItem)
|
||||
draggingItem.setDraggingFrame(self.bounds, contents: self.snapshot())
|
||||
@ -192,7 +192,7 @@ extension WorkspaceToolButton {
|
||||
|
||||
result.lockFocus()
|
||||
self.theme.barButtonHighlight.set()
|
||||
NSRectFill(rect)
|
||||
rect.fill()
|
||||
image.draw(in: rect)
|
||||
result.unlockFocus()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user