mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-28 02:54:31 +03:00
GH-286 Rename and use Any?
This commit is contained in:
parent
f3754ca27e
commit
109f498291
@ -1232,7 +1232,7 @@ extension NeoVimView: NeoVimUiBridgeProtocol {
|
|||||||
|
|
||||||
public func setTitle(_ title: String) {
|
public func setTitle(_ title: String) {
|
||||||
DispatchUtils.gui {
|
DispatchUtils.gui {
|
||||||
self.delegate?.setTitle(title)
|
self.delegate?.set(title: title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1241,7 +1241,7 @@ extension NeoVimView: NeoVimUiBridgeProtocol {
|
|||||||
|
|
||||||
public func setDirtyStatus(_ dirty: Bool) {
|
public func setDirtyStatus(_ dirty: Bool) {
|
||||||
DispatchUtils.gui {
|
DispatchUtils.gui {
|
||||||
self.delegate?.setDirtyStatus(dirty)
|
self.delegate?.set(dirtyStatus: dirty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ import Cocoa
|
|||||||
// See http://stackoverflow.com/a/24104371 for class
|
// See http://stackoverflow.com/a/24104371 for class
|
||||||
public protocol NeoVimViewDelegate: class {
|
public protocol NeoVimViewDelegate: class {
|
||||||
|
|
||||||
func setTitle(_ title: String)
|
func set(title: String)
|
||||||
func setDirtyStatus(_ dirty: Bool)
|
func set(dirtyStatus: Bool)
|
||||||
func cwdChanged()
|
func cwdChanged()
|
||||||
func neoVimStopped()
|
func neoVimStopped()
|
||||||
}
|
}
|
||||||
|
@ -15,16 +15,24 @@ enum MainWindowAction {
|
|||||||
|
|
||||||
class MainWindowComponent: WindowComponent, NSWindowDelegate {
|
class MainWindowComponent: WindowComponent, NSWindowDelegate {
|
||||||
|
|
||||||
fileprivate let fontManager = NSFontManager.shared()
|
fileprivate static let nibName = "MainWindow"
|
||||||
|
|
||||||
fileprivate var defaultEditorFont: NSFont
|
fileprivate var defaultEditorFont: NSFont
|
||||||
fileprivate var usesLigatures: Bool
|
fileprivate var usesLigatures: Bool
|
||||||
|
|
||||||
|
fileprivate var _cwd: URL = URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true)
|
||||||
|
|
||||||
|
fileprivate let fontManager = NSFontManager.shared()
|
||||||
|
fileprivate let fileItemService: FileItemService
|
||||||
|
|
||||||
|
fileprivate let workspace: Workspace
|
||||||
|
fileprivate let neoVimView: NeoVimView
|
||||||
|
|
||||||
|
// MARK: - API
|
||||||
var uuid: String {
|
var uuid: String {
|
||||||
return self.neoVimView.uuid
|
return self.neoVimView.uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate var _cwd: URL = URL(fileURLWithPath: NSHomeDirectory(), isDirectory: true)
|
|
||||||
var cwd: URL {
|
var cwd: URL {
|
||||||
get {
|
get {
|
||||||
self._cwd = self.neoVimView.cwd
|
self._cwd = self.neoVimView.cwd
|
||||||
@ -43,10 +51,6 @@ class MainWindowComponent: WindowComponent, NSWindowDelegate {
|
|||||||
self.fileItemService.monitor(url: newValue)
|
self.fileItemService.monitor(url: newValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileprivate let fileItemService: FileItemService
|
|
||||||
|
|
||||||
fileprivate let workspace: Workspace
|
|
||||||
fileprivate let neoVimView: NeoVimView
|
|
||||||
|
|
||||||
// TODO: Consider an option object for cwd, urls, etc...
|
// TODO: Consider an option object for cwd, urls, etc...
|
||||||
init(source: Observable<Any>,
|
init(source: Observable<Any>,
|
||||||
@ -66,7 +70,7 @@ class MainWindowComponent: WindowComponent, NSWindowDelegate {
|
|||||||
self.fileItemService = fileItemService
|
self.fileItemService = fileItemService
|
||||||
self._cwd = cwd
|
self._cwd = cwd
|
||||||
|
|
||||||
super.init(source: source, nibName: "MainWindow")
|
super.init(source: source, nibName: MainWindowComponent.nibName)
|
||||||
|
|
||||||
self.window.delegate = self
|
self.window.delegate = self
|
||||||
|
|
||||||
@ -99,6 +103,7 @@ class MainWindowComponent: WindowComponent, NSWindowDelegate {
|
|||||||
self.neoVimView.closeAllWindowsWithoutSaving()
|
self.neoVimView.closeAllWindowsWithoutSaving()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - WindowComponent
|
||||||
override func addViews() {
|
override func addViews() {
|
||||||
self.window.contentView?.addSubview(self.workspace)
|
self.window.contentView?.addSubview(self.workspace)
|
||||||
self.workspace.autoPinEdgesToSuperviewEdges()
|
self.workspace.autoPinEdgesToSuperviewEdges()
|
||||||
@ -122,11 +127,11 @@ class MainWindowComponent: WindowComponent, NSWindowDelegate {
|
|||||||
// MARK: - File Menu Items
|
// MARK: - File Menu Items
|
||||||
extension MainWindowComponent {
|
extension MainWindowComponent {
|
||||||
|
|
||||||
@IBAction func newTab(_ sender: AnyObject!) {
|
@IBAction func newTab(_ sender: Any?) {
|
||||||
self.neoVimView.newTab()
|
self.neoVimView.newTab()
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func openDocument(_ sender: AnyObject!) {
|
@IBAction func openDocument(_ sender: Any?) {
|
||||||
let panel = NSOpenPanel()
|
let panel = NSOpenPanel()
|
||||||
panel.canChooseDirectories = true
|
panel.canChooseDirectories = true
|
||||||
panel.beginSheetModal(for: self.window) { result in
|
panel.beginSheetModal(for: self.window) { result in
|
||||||
@ -139,11 +144,11 @@ extension MainWindowComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func openQuickly(_ sender: AnyObject!) {
|
@IBAction func openQuickly(_ sender: Any?) {
|
||||||
self.publish(event: MainWindowAction.openQuickly(mainWindow: self))
|
self.publish(event: MainWindowAction.openQuickly(mainWindow: self))
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func saveDocument(_ sender: AnyObject!) {
|
@IBAction func saveDocument(_ sender: Any?) {
|
||||||
let curBuf = self.neoVimView.currentBuffer()
|
let curBuf = self.neoVimView.currentBuffer()
|
||||||
|
|
||||||
if curBuf.fileName == nil {
|
if curBuf.fileName == nil {
|
||||||
@ -154,7 +159,7 @@ extension MainWindowComponent {
|
|||||||
self.neoVimView.saveCurrentTab()
|
self.neoVimView.saveCurrentTab()
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func saveDocumentAs(_ sender: AnyObject!) {
|
@IBAction func saveDocumentAs(_ sender: Any?) {
|
||||||
self.savePanelSheet { url in
|
self.savePanelSheet { url in
|
||||||
self.neoVimView.saveCurrentTab(url: url)
|
self.neoVimView.saveCurrentTab(url: url)
|
||||||
|
|
||||||
@ -196,18 +201,18 @@ extension MainWindowComponent {
|
|||||||
// MARK: - Font Menu Items
|
// MARK: - Font Menu Items
|
||||||
extension MainWindowComponent {
|
extension MainWindowComponent {
|
||||||
|
|
||||||
@IBAction func resetFontSize(_ sender: AnyObject!) {
|
@IBAction func resetFontSize(_ sender: Any?) {
|
||||||
self.neoVimView.font = self.defaultEditorFont
|
self.neoVimView.font = self.defaultEditorFont
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func makeFontBigger(_ sender: AnyObject!) {
|
@IBAction func makeFontBigger(_ sender: Any?) {
|
||||||
let curFont = self.neoVimView.font
|
let curFont = self.neoVimView.font
|
||||||
let font = self.fontManager.convert(curFont,
|
let font = self.fontManager.convert(curFont,
|
||||||
toSize: min(curFont.pointSize + 1, PrefStore.maximumEditorFontSize))
|
toSize: min(curFont.pointSize + 1, PrefStore.maximumEditorFontSize))
|
||||||
self.neoVimView.font = font
|
self.neoVimView.font = font
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func makeFontSmaller(_ sender: AnyObject!) {
|
@IBAction func makeFontSmaller(_ sender: Any?) {
|
||||||
let curFont = self.neoVimView.font
|
let curFont = self.neoVimView.font
|
||||||
let font = self.fontManager.convert(curFont,
|
let font = self.fontManager.convert(curFont,
|
||||||
toSize: max(curFont.pointSize - 1, PrefStore.minimumEditorFontSize))
|
toSize: max(curFont.pointSize - 1, PrefStore.minimumEditorFontSize))
|
||||||
@ -218,12 +223,12 @@ extension MainWindowComponent {
|
|||||||
// MARK: - NeoVimViewDelegate
|
// MARK: - NeoVimViewDelegate
|
||||||
extension MainWindowComponent: NeoVimViewDelegate {
|
extension MainWindowComponent: NeoVimViewDelegate {
|
||||||
|
|
||||||
func setTitle(_ title: String) {
|
func set(title: String) {
|
||||||
self.window.title = title
|
self.window.title = title
|
||||||
}
|
}
|
||||||
|
|
||||||
func setDirtyStatus(_ dirty: Bool) {
|
func set(dirtyStatus: Bool) {
|
||||||
self.windowController.setDocumentEdited(dirty)
|
self.windowController.setDocumentEdited(dirtyStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cwdChanged() {
|
func cwdChanged() {
|
||||||
|
Loading…
Reference in New Issue
Block a user