1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-22 13:11:55 +03:00
vimr/VimR/MainWindowController.swift
Tae Won Ha 4b4ccd13b3
GH-218 Add hasDirtyDocs()
- Use it to determine whether to close the window or not.
2016-07-18 20:16:56 +02:00

51 lines
1.1 KiB
Swift

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
import Cocoa
import PureLayout
class MainWindowController: NSWindowController, NSWindowDelegate, NeoVimViewDelegate {
var uuid: String {
return self.neoVimView.uuid
}
private weak var mainWindowManager: MainWindowManager?
private let neoVimView = NeoVimView(forAutoLayout: ())
func setup(manager manager: MainWindowManager) {
self.mainWindowManager = manager
self.neoVimView.delegate = self
self.addViews()
self.window?.makeFirstResponder(self.neoVimView)
}
// MARK: - NSWindowDelegate
func windowWillClose(notification: NSNotification) {
self.mainWindowManager?.closeMainWindow(self)
}
func windowShouldClose(sender: AnyObject) -> Bool {
return !self.neoVimView.hasDirtyDocs()
}
// MARK: - NeoVimViewDelegate
func setNeoVimTitle(title: String) {
NSLog("\(#function): \(title)")
}
func neoVimStopped() {
self.close()
}
// MARK: - Private
private func addViews() {
self.window?.contentView?.addSubview(self.neoVimView)
self.neoVimView.autoPinEdgesToSuperviewEdges()
}
}