From 72180f8a9b1c332c3872d29bd3fa7784f4a72e51 Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Fri, 8 Mar 2019 07:33:43 +0100 Subject: [PATCH 1/6] Adapt the new CocoaFontAwesome API --- Cartfile.resolved | 2 +- VimR/VimR/AppDelegate.swift | 2 +- VimR/VimR/FileBrowser.swift | 30 +++-- VimR/VimR/FileOutlineView.swift | 4 + VimR/VimR/HtmlPreviewTool.swift | 5 +- VimR/VimR/Workspace/InnterToolBar.swift | 150 +++++++++++++++--------- 6 files changed, 123 insertions(+), 70 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index 124ed6d3..b515eb5b 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -6,7 +6,7 @@ github "a2/MessagePack.swift" "3.0.0" github "elegantchaos/DictionaryCoding" "1.0.6" github "eonil/FileSystemEvents" "1.0.0" github "httpswift/swifter" "1.4.5" -github "qvacua/CocoaFontAwesome" "c4d9ac161c43a7d22ae711d112ca6c6d90c86b52" +github "qvacua/CocoaFontAwesome" "02bc18dcff2197d55007144e09e5db53a7cb0458" github "qvacua/CocoaMarkdown" "c58166490a71ad4d8466f7e7b9faf7cb0917c42f" github "qvacua/RxMessagePort" "v0.0.6" github "qvacua/RxMsgpackRpc" "v0.0.8" diff --git a/VimR/VimR/AppDelegate.swift b/VimR/VimR/AppDelegate.swift index f18af356..21f478dc 100644 --- a/VimR/VimR/AppDelegate.swift +++ b/VimR/VimR/AppDelegate.swift @@ -69,7 +69,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele // Check whether FontAwesome can be loaded. If not, show a warning. // We don't know yet why this happens to some users. DispatchQueue.main.async { - guard NSFont.fontAwesome(ofSize: 13) == nil else { + guard NSFont.fontAwesome(ofSize: 13, style: .regular) == nil else { return } diff --git a/VimR/VimR/FileBrowser.swift b/VimR/VimR/FileBrowser.swift index 671df4b5..df2bfa1b 100644 --- a/VimR/VimR/FileBrowser.swift +++ b/VimR/VimR/FileBrowser.swift @@ -106,15 +106,18 @@ extension FileBrowser { } override func repaint(with theme: Workspace.Theme) { - self.goToParentButton.image = NSImage.fontAwesomeIcon(name: .levelUp, + self.goToParentButton.image = NSImage.fontAwesomeIcon(name: .levelUpAlt, + style: .solid, textColor: theme.toolbarForeground, dimension: InnerToolBar.iconDimension) self.scrollToSourceButton.image = NSImage.fontAwesomeIcon(name: .bullseye, + style: .solid, textColor: theme.toolbarForeground, dimension: InnerToolBar.iconDimension) - self.refreshButton.image = NSImage.fontAwesomeIcon(name: .refresh, + self.refreshButton.image = NSImage.fontAwesomeIcon(name: .sync, + style: .solid, textColor: theme.toolbarForeground, dimension: InnerToolBar.iconDimension) } @@ -129,17 +132,17 @@ extension FileBrowser { private func addViews() { let goToParent = self.goToParentButton - InnerToolBar.configureToStandardIconButton(button: goToParent, iconName: .levelUp) + InnerToolBar.configureToStandardIconButton(button: goToParent, iconName: .levelUpAlt, style: .solid) goToParent.toolTip = "Set parent as working directory" goToParent.action = #selector(FileBrowser.goToParentAction) let scrollToSource = self.scrollToSourceButton - InnerToolBar.configureToStandardIconButton(button: scrollToSource, iconName: .bullseye) + InnerToolBar.configureToStandardIconButton(button: scrollToSource, iconName: .bullseye, style: .solid) scrollToSource.toolTip = "Navigate to the current buffer" scrollToSource.action = #selector(FileBrowser.scrollToSourceAction) let refresh = self.refreshButton - InnerToolBar.configureToStandardIconButton(button: refresh, iconName: .refresh) + InnerToolBar.configureToStandardIconButton(button: refresh, iconName: .sync, style: .solid) refresh.toolTip = "Refresh" refresh.action = #selector(FileBrowser.refreshAction) @@ -148,11 +151,22 @@ extension FileBrowser { self.addSubview(refresh) refresh.autoPinEdge(toSuperviewEdge: .top) - refresh.autoPinEdge(toSuperviewEdge: .right) + refresh.autoPinEdge(toSuperviewEdge: .right, + withInset: InnerToolBar.itemPadding) goToParent.autoPinEdge(toSuperviewEdge: .top) - goToParent.autoPinEdge(.right, to: .left, of: refresh) + goToParent.autoPinEdge( + .right, + to: .left, + of: refresh, + withOffset: -InnerToolBar.itemPadding + ) scrollToSource.autoPinEdge(toSuperviewEdge: .top) - scrollToSource.autoPinEdge(.right, to: .left, of: goToParent) + scrollToSource.autoPinEdge( + .right, + to: .left, + of: goToParent, + withOffset: -InnerToolBar.itemPadding + ) } required init?(coder: NSCoder) { diff --git a/VimR/VimR/FileOutlineView.swift b/VimR/VimR/FileOutlineView.swift index c4be8e1a..1a82b312 100644 --- a/VimR/VimR/FileOutlineView.swift +++ b/VimR/VimR/FileOutlineView.swift @@ -34,11 +34,13 @@ class FileOutlineView: NSOutlineView, self.isShowHidden = state.fileBrowserShowHidden self.triangleClosed = NSImage.fontAwesomeIcon( name: .caretRight, + style: .solid, textColor: self.theme.directoryForeground, dimension: triangleImageSize ) self.triangleOpen = NSImage.fontAwesomeIcon( name: .caretDown, + style: .solid, textColor: self.theme.directoryForeground, dimension: triangleImageSize ) @@ -279,11 +281,13 @@ class FileOutlineView: NSOutlineView, self.backgroundColor = self.theme.background self.triangleClosed = NSImage.fontAwesomeIcon( name: .caretRight, + style: .solid, textColor: self.theme.directoryForeground, dimension: triangleImageSize ) self.triangleOpen = NSImage.fontAwesomeIcon( name: .caretDown, + style: .solid, textColor: self.theme.directoryForeground, dimension: triangleImageSize ) diff --git a/VimR/VimR/HtmlPreviewTool.swift b/VimR/VimR/HtmlPreviewTool.swift index 847e8d1c..055f9451 100644 --- a/VimR/VimR/HtmlPreviewTool.swift +++ b/VimR/VimR/HtmlPreviewTool.swift @@ -154,14 +154,15 @@ extension HtmlPreviewTool { private func addViews() { let selectHtmlFile = self.selectHtmlFile - InnerToolBar.configureToStandardIconButton(button: selectHtmlFile, iconName: .fileCodeO) + InnerToolBar.configureToStandardIconButton(button: selectHtmlFile, iconName: .fileCode, style: .regular) selectHtmlFile.toolTip = "Select the HTML file" selectHtmlFile.action = #selector(HtmlPreviewTool.selectHtmlFile) self.addSubview(selectHtmlFile) selectHtmlFile.autoPinEdge(toSuperviewEdge: .top) - selectHtmlFile.autoPinEdge(toSuperviewEdge: .right) + selectHtmlFile.autoPinEdge(toSuperviewEdge: .right, + withInset: InnerToolBar.itemPadding) } required init?(coder: NSCoder) { diff --git a/VimR/VimR/Workspace/InnterToolBar.swift b/VimR/VimR/Workspace/InnterToolBar.swift index 7bf8783d..387eb625 100644 --- a/VimR/VimR/Workspace/InnterToolBar.swift +++ b/VimR/VimR/Workspace/InnterToolBar.swift @@ -21,33 +21,23 @@ class CustomToolBar: NSView { */ class InnerToolBar: NSView, NSUserInterfaceValidations { - private static let separatorThickness = CGFloat(1) - private static let height = InnerToolBar.iconDimension + 2 + 2 + InnerToolBar.separatorThickness - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - private let titleField = NSTextField(forAutoLayout: ()) - private let closeButton = NSButton(forAutoLayout: ()) - private let cogButton = NSPopUpButton(forAutoLayout: ()) - - private let locToSelector: [WorkspaceBarLocation: Selector] = [ - .top: #selector(InnerToolBar.moveToTopAction(_:)), - .right: #selector(InnerToolBar.moveToRightAction(_:)), - .bottom: #selector(InnerToolBar.moveToBottomAction(_:)), - .left: #selector(InnerToolBar.moveToLeftAction(_:)), - ] - // MARK: - API static let toolbarHeight = InnerToolBar.iconDimension - static let iconDimension = CGFloat(19) + static let iconDimension = CGFloat(18) + static let itemPadding = CGFloat(4) - static func configureToStandardIconButton(button: NSButton, - iconName: CocoaFontAwesome.FontAwesome, - color: NSColor = Workspace.Theme.default.toolbarForeground) { - - let icon = NSImage.fontAwesomeIcon(name: iconName, textColor: color, dimension: InnerToolBar.iconDimension) + static func configureToStandardIconButton( + button: NSButton, + iconName: FontAwesome, + style: FontAwesomeStyle, + color: NSColor = Workspace.Theme.default.toolbarForeground + ) { + let icon = NSImage.fontAwesomeIcon( + name: iconName, + style: .solid, + textColor: color, + dimension: InnerToolBar.iconDimension + ) button.imagePosition = .imageOnly button.image = icon @@ -112,12 +102,18 @@ class InnerToolBar: NSView, NSUserInterfaceValidations { self.layer!.backgroundColor = self.theme.toolbarBackground.cgColor self.titleField.textColor = self.theme.toolbarForeground - self.cogButton.menu?.item(at: 0)?.image = NSImage.fontAwesomeIcon(name: .cog, - textColor: self.theme.toolbarForeground, - dimension: InnerToolBar.iconDimension) - self.closeButton.image = NSImage.fontAwesomeIcon(name: .timesCircle, - textColor: self.theme.toolbarForeground, - dimension: InnerToolBar.iconDimension) + self.cogButton.image = NSImage.fontAwesomeIcon( + name: .cog, + style: .solid, + textColor: self.theme.toolbarForeground, + dimension: InnerToolBar.iconDimension + ) + self.closeButton.image = NSImage.fontAwesomeIcon( + name: .timesCircle, + style: .regular, + textColor: self.theme.toolbarForeground, + dimension: InnerToolBar.iconDimension + ) self.customToolbar?.repaint(with: self.theme) @@ -138,6 +134,25 @@ class InnerToolBar: NSView, NSUserInterfaceValidations { } } + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private static let separatorThickness = CGFloat(1) + private static let height = InnerToolBar.iconDimension + 2 + 2 + InnerToolBar.separatorThickness + + private let titleField = NSTextField(forAutoLayout: ()) + private let closeButton = NSButton(forAutoLayout: ()) + private let cogButton = NSButton(forAutoLayout: ()) + private let cogMenu = NSMenu() + + private let locToSelector: [WorkspaceBarLocation: Selector] = [ + .top: #selector(InnerToolBar.moveToTopAction(_:)), + .right: #selector(InnerToolBar.moveToRightAction(_:)), + .bottom: #selector(InnerToolBar.moveToBottomAction(_:)), + .left: #selector(InnerToolBar.moveToLeftAction(_:)), + ] + private func removeCustomUiElements() { self.customToolbar?.removeFromSuperview() [self.titleField, self.closeButton, self.cogButton].forEach { $0.removeFromSuperview() } @@ -155,27 +170,23 @@ class InnerToolBar: NSView, NSUserInterfaceValidations { title.isSelectable = false title.controlSize = .small - InnerToolBar.configureToStandardIconButton(button: close, - iconName: .timesCircle, - color: self.theme.toolbarForeground) + InnerToolBar.configureToStandardIconButton( + button: close, + iconName: .timesCircle, + style: .regular, + color: self.theme.toolbarForeground + ) close.target = self close.action = #selector(InnerToolBar.closeAction) - let cogIcon = NSImage.fontAwesomeIcon(name: .cog, - textColor: self.theme.toolbarForeground, - dimension: InnerToolBar.iconDimension) - cog.configureForAutoLayout() - cog.imagePosition = .imageOnly - cog.pullsDown = true - cog.isBordered = false - - let cogCell = cog.cell as? NSPopUpButtonCell - cogCell?.arrowPosition = .noArrow - - let cogMenu = NSMenu() - - let cogMenuItem = NSMenuItem(title: "Cog", action: nil, keyEquivalent: "") - cogMenuItem.image = cogIcon + InnerToolBar.configureToStandardIconButton( + button: cog, + iconName: .cog, + style: .solid, + color: self.theme.toolbarForeground + ) + cog.action = #selector(InnerToolBar.cogAction) + cog.target = self let moveToMenu = NSMenu() let topMenuItem = NSMenuItem(title: "Top", @@ -207,8 +218,6 @@ class InnerToolBar: NSView, NSUserInterfaceValidations { ) moveToMenuItem.submenu = moveToMenu - cogMenu.addItem(cogMenuItem) - if self.customMenuItems?.isEmpty == false { self.customMenuItems?.forEach(cogMenu.addItem) cogMenu.addItem(NSMenuItem.separator()) @@ -216,8 +225,6 @@ class InnerToolBar: NSView, NSUserInterfaceValidations { cogMenu.addItem(moveToMenuItem) - cog.menu = cogMenu - if let customToolbar = self.customToolbar { customToolbar.configureForAutoLayout() self.addSubview(customToolbar) @@ -232,14 +239,32 @@ class InnerToolBar: NSView, NSUserInterfaceValidations { close.autoPinEdge(toSuperviewEdge: .top, withInset: 2) close.autoPinEdge(toSuperviewEdge: .right, withInset: 2) - cog.autoPinEdge(.right, to: .left, of: close, withOffset: 5) - cog.autoPinEdge(toSuperviewEdge: .top, withInset: -1) + cog.autoPinEdge( + .right, + to: .left, + of: close, + withOffset: -InnerToolBar.itemPadding + ) + cog.autoPinEdge(.top, to: .top, of: close) if let customToolbar = self.customToolbar { customToolbar.autoPinEdge(toSuperviewEdge: .top, withInset: 2) - customToolbar.autoPinEdge(.right, to: .left, of: cog, withOffset: 5 - InnerToolBar.separatorThickness) - customToolbar.autoPinEdge(toSuperviewEdge: .bottom, withInset: 2 + InnerToolBar.separatorThickness) - customToolbar.autoPinEdge(.left, to: .right, of: title, withOffset: 2) + customToolbar.autoPinEdge( + .right, + to: .left, + of: cog, + withOffset: -InnerToolBar.itemPadding - InnerToolBar.separatorThickness + ) + customToolbar.autoPinEdge( + toSuperviewEdge: .bottom, + withInset: 2 + InnerToolBar.separatorThickness + ) + customToolbar.autoPinEdge( + .left, + to: .right, + of: title, + withOffset: -InnerToolBar.itemPadding + ) } } @@ -251,7 +276,10 @@ class InnerToolBar: NSView, NSUserInterfaceValidations { private func innerSeparatorRect() -> CGRect { let cogBounds = self.cogButton.frame let bounds = self.bounds - return CGRect(x: cogBounds.minX + 6, y: bounds.minY + 4, width: 1, height: bounds.height - 4 - 4) + return CGRect(x: cogBounds.minX - InnerToolBar.itemPadding, + y: bounds.minY + 4, + width: 1, + height: bounds.height - 4 - 4) } } @@ -262,6 +290,12 @@ extension InnerToolBar { self.tool?.toggle() } + @objc func cogAction(_ sender: NSButton) { + guard let event = NSApp.currentEvent else { return } + + NSMenu.popUpContextMenu(self.cogMenu, with: event, for: sender) + } + @objc func moveToTopAction(_ sender: Any?) { self.move(to: .top) } From c2911274059665cce0926bb546e7163c6f50aa6c Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Fri, 8 Mar 2019 09:56:30 +0100 Subject: [PATCH 2/6] Fix broken "Navigate to the current buffer" of the file browser --- VimR/VimR.xcodeproj/project.pbxproj | 10 ------ VimR/VimR/FileBrowser.swift | 2 -- VimR/VimR/FileOutlineView.swift | 44 +++++++++++++++++++++++++++ VimR/VimRTests/ArrayCommonsTest.swift | 6 ---- 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/VimR/VimR.xcodeproj/project.pbxproj b/VimR/VimR.xcodeproj/project.pbxproj index 0656d0c1..ee6b9b90 100644 --- a/VimR/VimR.xcodeproj/project.pbxproj +++ b/VimR/VimR.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 1929B0244BD7111E168726CF /* DefaultShortcuts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B93256AF7F9137223E36 /* DefaultShortcuts.swift */; }; 1929B04CE8ECBD75CBBB0991 /* StringCommonsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B5D45C9792BBE76B8AFF /* StringCommonsTest.swift */; }; 1929B05B9D664052EC2D23EF /* FileOutlineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BCE3E156C06EDF1F2806 /* FileOutlineView.swift */; }; 1929B08C6230B9C5AB72DAF1 /* Pref128ToCurrentConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B5046239709E33516F5C /* Pref128ToCurrentConverter.swift */; }; @@ -27,7 +26,6 @@ 1929B3AC66EFE35D68C020E3 /* PreviewToolReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BFB0F294F3714D5E095F /* PreviewToolReducer.swift */; }; 1929B3F5743967125F357C9F /* Matcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BEEB33113B0E33C3830F /* Matcher.swift */; }; 1929B462CD4935AFF6D69457 /* FileItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B7CB4863F80230C32D3C /* FileItem.swift */; }; - 1929B489A51FD5B13888A00C /* RpcEvents.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BBF0944940845485A512 /* RpcEvents.swift */; }; 1929B4B00D7BB191A9A6532D /* HtmlPreviewToolReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BE5AEA3D0980860EED50 /* HtmlPreviewToolReducer.swift */; }; 1929B4B70926DE113E6BF990 /* PreviewReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BE37AA2843779CAFA76F /* PreviewReducer.swift */; }; 1929B4E54E2F13A7F5F2B682 /* BufferListReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B67A10E6BB2986B2416E /* BufferListReducer.swift */; }; @@ -70,17 +68,14 @@ 1929BB67CAAD4F6CBD38DF0A /* RxRedux.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B66A5E2D00EA143AFD86 /* RxRedux.swift */; }; 1929BB85B2D30E548A32663D /* ShortcutsPref.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B0E9B2F018D3E31D4B0B /* ShortcutsPref.swift */; }; 1929BBE28654E4307AF1E2FD /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BC2F05E9A5C0DB039739 /* Theme.swift */; }; - 1929BC682EA78BF50D1E0890 /* ShortcutsTableSubviews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B07F0085B7AE10413346 /* ShortcutsTableSubviews.swift */; }; 1929BCC7908DD899999B70BE /* AppearancePrefReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BED01F5D94BFCA4CF80F /* AppearancePrefReducer.swift */; }; 1929BCC9D3604933DFF07E2E /* FileBrowser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BA5C7099CDEB04B76BA4 /* FileBrowser.swift */; }; 1929BCF7F7B9CC5499A3F506 /* AdvancedPrefReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B7039C5689CE45F53888 /* AdvancedPrefReducer.swift */; }; 1929BD2F41D93ADFF43C1C98 /* NetUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 1929B02440BC99C42F9EBD45 /* NetUtils.m */; }; 1929BD3878A3A47B8D685CD2 /* AppDelegateReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B7A68B7109CEFAF105E8 /* AppDelegateReducer.swift */; }; 1929BD3F9E609BFADB27584B /* Scorer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B9D510177918080BE39B /* Scorer.swift */; }; - 1929BDC69A5F9D1661423488 /* ShortcutItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BF230875DED6CD7AB3EB /* ShortcutItem.swift */; }; 1929BDFDBDA7180D02ACB37E /* RxSwiftCommonsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B6C215ACCBE12672A8D7 /* RxSwiftCommonsTest.swift */; }; 1929BE0DAEE9664C5BCFA211 /* States.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BB6608B4F0E037CA0F4C /* States.swift */; }; - 1929BE0EB11D6BBC46D448D2 /* RpcAppearanceEpic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B230EE8F1428980988F0 /* RpcAppearanceEpic.swift */; }; 1929BE0F64A6CE5BCE2A5092 /* MainWindow+Delegates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B714EB137AE448CE8ABD /* MainWindow+Delegates.swift */; }; 1929BE2F3E0182CC51F2763A /* ThemedTableSubviews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929BD2CA8DD198A6BCDBCB7 /* ThemedTableSubviews.swift */; }; 1929BEAE0592096BC1191B67 /* PrefPane.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1929B07A4A9209C88380E015 /* PrefPane.swift */; }; @@ -1235,11 +1230,6 @@ 1929B8E90A1378E494D481E7 /* PrefUtilsTest.swift in Sources */, 1929B20CE35B43BB1CE023BA /* Theme.swift in Sources */, 1929B9318D32146D58BB38EC /* AppKitCommons.swift in Sources */, - 1929BC682EA78BF50D1E0890 /* ShortcutsTableSubviews.swift in Sources */, - 1929B0244BD7111E168726CF /* DefaultShortcuts.swift in Sources */, - 1929BDC69A5F9D1661423488 /* ShortcutItem.swift in Sources */, - 1929B489A51FD5B13888A00C /* RpcEvents.swift in Sources */, - 1929BE0EB11D6BBC46D448D2 /* RpcAppearanceEpic.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/VimR/VimR/FileBrowser.swift b/VimR/VimR/FileBrowser.swift index df2bfa1b..5d0ed3e1 100644 --- a/VimR/VimR/FileBrowser.swift +++ b/VimR/VimR/FileBrowser.swift @@ -195,9 +195,7 @@ extension FileBrowser { return } - #if NOPE self.fileView.select(url) - #endif } @objc func refreshAction(_ sender: Any?) { diff --git a/VimR/VimR/FileOutlineView.swift b/VimR/VimR/FileOutlineView.swift index 1a82b312..a9ff3919 100644 --- a/VimR/VimR/FileOutlineView.swift +++ b/VimR/VimR/FileOutlineView.swift @@ -125,6 +125,50 @@ class FileOutlineView: NSOutlineView, return result } + private func select(treeNode: NSTreeNode) { + let targetRow = self.row(forItem: treeNode) + self.selectRowIndexes(IndexSet(integer: targetRow), byExtendingSelection: false) + self.scrollRowToVisible(targetRow) + } + + func select(_ url: URL) { + guard let childrenOfRoot = self.treeController.arrangedObjects.children + else { return } + + var stack = [NSTreeNode]() + + // NSTreeController.arrangedObjects has no Node. + for childOfRoot in childrenOfRoot { + guard let node = childOfRoot.node else { continue } + + stdoutLog.debug(node) + if node.url == url { + self.select(treeNode: childOfRoot) + return + } + + if node.url.isParent(of: url) { + self.expandItem(childOfRoot) + stack.append(contentsOf: childOfRoot.children ?? []) + break + } + } + + while let item = stack.popLast() { + self.expandItem(item) + + guard let node = item.node else { continue } + if node.url == url { + self.select(treeNode: item) + return + } + + if node.url.isParent(of: url) { + stack.append(contentsOf: item.children ?? []) + } + } + } + required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } diff --git a/VimR/VimRTests/ArrayCommonsTest.swift b/VimR/VimRTests/ArrayCommonsTest.swift index d694107f..39875ec8 100644 --- a/VimR/VimRTests/ArrayCommonsTest.swift +++ b/VimR/VimRTests/ArrayCommonsTest.swift @@ -25,12 +25,6 @@ fileprivate class DummyToken: Comparable { class ArrayCommonsTest: XCTestCase { - func testConcurrentChunkMap() { - let array = Array(0...1000) - let result = array.concurrentChunkMap(100, queue: .global(qos: .userInitiated)) { "\($0)" } - expect(Set(result)).to(equal(Set(array.map { "\($0)" }))) - } - func testTuplesToDict() { let tuples = [ (1, "1"), From c7582826af9ea55f696242f6bf4093c8c31b8a32 Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Fri, 8 Mar 2019 09:59:30 +0100 Subject: [PATCH 3/6] Update release notes --- resources/release-notes.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/release-notes.md b/resources/release-notes.md index 39da54a1..fb8f14ae 100644 --- a/resources/release-notes.md +++ b/resources/release-notes.md @@ -2,6 +2,12 @@ * ... +# 0.26.1-??? + +* Fix broken "Navigate to the current buffer" of the file browser +* Dependencies updates: + - Use FontAwesome 5 (thanks for the PR, @chriszielinski!) + # 0.26.0-303 * Minimum macOS requirement is now 10.12 Sierra. From 6457767f7e668bd9bc3b6e38ac8bb685f2214db8 Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Fri, 8 Mar 2019 10:09:24 +0100 Subject: [PATCH 4/6] Remove FontAwesome check --- Cartfile.resolved | 2 +- VimR/VimR/AppDelegate.swift | 19 ------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/Cartfile.resolved b/Cartfile.resolved index b515eb5b..4154d8aa 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -6,7 +6,7 @@ github "a2/MessagePack.swift" "3.0.0" github "elegantchaos/DictionaryCoding" "1.0.6" github "eonil/FileSystemEvents" "1.0.0" github "httpswift/swifter" "1.4.5" -github "qvacua/CocoaFontAwesome" "02bc18dcff2197d55007144e09e5db53a7cb0458" +github "qvacua/CocoaFontAwesome" "fc2a08babd676525ced68061b19ad8ff3dd1d0b3" github "qvacua/CocoaMarkdown" "c58166490a71ad4d8466f7e7b9faf7cb0917c42f" github "qvacua/RxMessagePort" "v0.0.6" github "qvacua/RxMsgpackRpc" "v0.0.8" diff --git a/VimR/VimR/AppDelegate.swift b/VimR/VimR/AppDelegate.swift index 21f478dc..93df8cfb 100644 --- a/VimR/VimR/AppDelegate.swift +++ b/VimR/VimR/AppDelegate.swift @@ -63,25 +63,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele self.useSnapshot = initialAppState.useSnapshotUpdate super.init() - - NSUserNotificationCenter.default.delegate = self - // FIXME: GH-611: https://github.com/qvacua/vimr/issues/611 - // Check whether FontAwesome can be loaded. If not, show a warning. - // We don't know yet why this happens to some users. - DispatchQueue.main.async { - guard NSFont.fontAwesome(ofSize: 13, style: .regular) == nil else { - return - } - - let notification = NSUserNotification() - notification.title = "FontAwesome could not be loaded." - notification.subtitle = "Unfortunately we don't know yet what is causing this." - notification.informativeText = """ - We use the FontAwesome font for icons in the tools, e.g. the file browser. Those icons are now shown as ?. - You can track the progress on this issue at GitHub issue 611. - """ - NSUserNotificationCenter.default.deliver(notification) - } } override func awakeFromNib() { From 965c0b0e2bd48631ebb03ed8b8a8d29112489547 Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Fri, 8 Mar 2019 10:17:17 +0100 Subject: [PATCH 5/6] Bump version: v0.26.1-304 --- NvimView/DrawerDev/Info.plist | 4 ++-- NvimView/NvimView.xcodeproj/project.pbxproj | 8 ++++---- NvimView/NvimView/Info.plist | 4 ++-- NvimView/NvimViewTests/Info.plist | 4 ++-- VimR/VimR.xcodeproj/project.pbxproj | 4 ++-- VimR/VimR/Info.plist | 4 ++-- VimR/VimRTests/Info.plist | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/NvimView/DrawerDev/Info.plist b/NvimView/DrawerDev/Info.plist index ca843cf0..11fcfa85 100644 --- a/NvimView/DrawerDev/Info.plist +++ b/NvimView/DrawerDev/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.26.0 + 0.26.1 CFBundleVersion - 303 + 304 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSHumanReadableCopyright diff --git a/NvimView/NvimView.xcodeproj/project.pbxproj b/NvimView/NvimView.xcodeproj/project.pbxproj index 1a48200c..fa1ada39 100644 --- a/NvimView/NvimView.xcodeproj/project.pbxproj +++ b/NvimView/NvimView.xcodeproj/project.pbxproj @@ -803,7 +803,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 303; + CURRENT_PROJECT_VERSION = 304; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -865,7 +865,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 303; + CURRENT_PROJECT_VERSION = 304; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -894,7 +894,7 @@ COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 303; + DYLIB_CURRENT_VERSION = 304; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac"; FRAMEWORK_VERSION = A; @@ -916,7 +916,7 @@ COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 303; + DYLIB_CURRENT_VERSION = 304; DYLIB_INSTALL_NAME_BASE = "@rpath"; FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac"; FRAMEWORK_VERSION = A; diff --git a/NvimView/NvimView/Info.plist b/NvimView/NvimView/Info.plist index 9c2a1908..cfa5d6eb 100644 --- a/NvimView/NvimView/Info.plist +++ b/NvimView/NvimView/Info.plist @@ -15,9 +15,9 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.26.0 + 0.26.1 CFBundleVersion - 303 + 304 NSHumanReadableCopyright Copyright © 2017 Tae Won Ha. All rights reserved. NSPrincipalClass diff --git a/NvimView/NvimViewTests/Info.plist b/NvimView/NvimViewTests/Info.plist index dfe9f10c..922a5377 100644 --- a/NvimView/NvimViewTests/Info.plist +++ b/NvimView/NvimViewTests/Info.plist @@ -15,8 +15,8 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 0.26.0 + 0.26.1 CFBundleVersion - 303 + 304 diff --git a/VimR/VimR.xcodeproj/project.pbxproj b/VimR/VimR.xcodeproj/project.pbxproj index ee6b9b90..acea6ccb 100644 --- a/VimR/VimR.xcodeproj/project.pbxproj +++ b/VimR/VimR.xcodeproj/project.pbxproj @@ -1324,7 +1324,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 303; + CURRENT_PROJECT_VERSION = 304; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -1382,7 +1382,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 303; + CURRENT_PROJECT_VERSION = 304; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; diff --git a/VimR/VimR/Info.plist b/VimR/VimR/Info.plist index 63dc4da9..61ef4a44 100644 --- a/VimR/VimR/Info.plist +++ b/VimR/VimR/Info.plist @@ -1224,7 +1224,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.26.0 + 0.26.1 CFBundleSignature ???? CFBundleURLTypes @@ -1241,7 +1241,7 @@ CFBundleVersion - 303 + 304 LSApplicationCategoryType public.app-category.productivity LSMinimumSystemVersion diff --git a/VimR/VimRTests/Info.plist b/VimR/VimRTests/Info.plist index 389683f6..34d4a3d8 100644 --- a/VimR/VimRTests/Info.plist +++ b/VimR/VimRTests/Info.plist @@ -15,10 +15,10 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 0.26.0 + 0.26.1 CFBundleSignature ???? CFBundleVersion - 303 + 304 From 17d5bcfc1d318aba7d09f78f4b310cd8b4bdd938 Mon Sep 17 00:00:00 2001 From: Tae Won Ha Date: Fri, 8 Mar 2019 10:19:56 +0100 Subject: [PATCH 6/6] Bump appcast(s) to v0.26.1-304 --- appcast.xml | 28 +++++++++++++--------------- appcast_snapshot.xml | 28 +++++++++++++--------------- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/appcast.xml b/appcast.xml index 035ae9fe..e53b9bf8 100644 --- a/appcast.xml +++ b/appcast.xml @@ -7,28 +7,26 @@ Most recent changes with links to updates for VimR. en - v0.26.0-303 + v0.26.1-304 -
  • Minimum macOS requirement is now 10.12 Sierra.
  • -
  • Optional parallel computation of glyphs. This may result in faster rendering depending on the situation.
  • -
  • GH-314: You can customize the key shortcut for all menu items in the Shortcut preferences pane.
  • -
  • GH-501: Add key shortcuts to toggle the Buffer List, Markdown Preview, and HTML Preview tools.
  • -
  • GH-649: Add commands that can control some of GUI elements.
  • -
  • GH-506: Set font, size and linespacing via ~/.config/nvim/ginit.vim.
  • -
  • Draw the disclosure triangle in appropriate color of the current color scheme (and improve handling of changes of cwd in the file browser).
  • +
  • Fix broken "Navigate to the current buffer" of the file browser
  • +
  • Dependencies updates:
      +
    • Use FontAwesome 5 (thanks for the PR, @chriszielinski!)
    • +
    +
  • ]]>
    - https://github.com/qvacua/vimr/releases/tag/v0.26.0-303 + https://github.com/qvacua/vimr/releases/tag/v0.26.1-304 - 2019-03-06T16:41:54.852561 + 2019-03-08T10:19:56.833987 10.10.0 -
    diff --git a/appcast_snapshot.xml b/appcast_snapshot.xml index 035ae9fe..e53b9bf8 100644 --- a/appcast_snapshot.xml +++ b/appcast_snapshot.xml @@ -7,28 +7,26 @@ Most recent changes with links to updates for VimR. en - v0.26.0-303 + v0.26.1-304 -
  • Minimum macOS requirement is now 10.12 Sierra.
  • -
  • Optional parallel computation of glyphs. This may result in faster rendering depending on the situation.
  • -
  • GH-314: You can customize the key shortcut for all menu items in the Shortcut preferences pane.
  • -
  • GH-501: Add key shortcuts to toggle the Buffer List, Markdown Preview, and HTML Preview tools.
  • -
  • GH-649: Add commands that can control some of GUI elements.
  • -
  • GH-506: Set font, size and linespacing via ~/.config/nvim/ginit.vim.
  • -
  • Draw the disclosure triangle in appropriate color of the current color scheme (and improve handling of changes of cwd in the file browser).
  • +
  • Fix broken "Navigate to the current buffer" of the file browser
  • +
  • Dependencies updates:
      +
    • Use FontAwesome 5 (thanks for the PR, @chriszielinski!)
    • +
    +
  • ]]>
    - https://github.com/qvacua/vimr/releases/tag/v0.26.0-303 + https://github.com/qvacua/vimr/releases/tag/v0.26.1-304 - 2019-03-06T16:41:54.852561 + 2019-03-08T10:19:56.833987 10.10.0 -