2016-07-10 19:47:24 +03:00
|
|
|
/**
|
|
|
|
* Tae Won Ha - http://taewon.de - @hataewon
|
|
|
|
* See LICENSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
import PureLayout
|
|
|
|
|
2016-07-17 15:41:53 +03:00
|
|
|
class MainWindowController: NSWindowController, NSWindowDelegate, NeoVimViewDelegate {
|
2016-07-10 19:47:24 +03:00
|
|
|
|
|
|
|
var uuid: String {
|
|
|
|
return self.neoVimView.uuid
|
|
|
|
}
|
|
|
|
|
2016-07-11 18:56:55 +03:00
|
|
|
private weak var mainWindowManager: MainWindowManager?
|
2016-07-10 19:47:24 +03:00
|
|
|
|
|
|
|
private let neoVimView = NeoVimView(forAutoLayout: ())
|
|
|
|
|
2016-07-11 18:56:55 +03:00
|
|
|
func setup(manager manager: MainWindowManager) {
|
2016-07-10 19:47:24 +03:00
|
|
|
self.mainWindowManager = manager
|
2016-07-17 15:41:53 +03:00
|
|
|
self.neoVimView.delegate = self
|
2016-07-10 19:47:24 +03:00
|
|
|
self.addViews()
|
2016-07-11 18:56:55 +03:00
|
|
|
|
2016-07-10 19:47:24 +03:00
|
|
|
self.window?.makeFirstResponder(self.neoVimView)
|
|
|
|
}
|
2016-07-11 18:56:55 +03:00
|
|
|
|
2016-07-18 21:16:56 +03:00
|
|
|
// MARK: - NSWindowDelegate
|
2016-07-10 19:47:24 +03:00
|
|
|
func windowWillClose(notification: NSNotification) {
|
|
|
|
self.mainWindowManager?.closeMainWindow(self)
|
|
|
|
}
|
2016-07-18 21:16:56 +03:00
|
|
|
|
|
|
|
func windowShouldClose(sender: AnyObject) -> Bool {
|
|
|
|
return !self.neoVimView.hasDirtyDocs()
|
|
|
|
}
|
|
|
|
|
|
|
|
// MARK: - NeoVimViewDelegate
|
2016-07-17 15:41:53 +03:00
|
|
|
func setNeoVimTitle(title: String) {
|
|
|
|
NSLog("\(#function): \(title)")
|
|
|
|
}
|
|
|
|
|
|
|
|
func neoVimStopped() {
|
2016-07-18 21:16:56 +03:00
|
|
|
self.close()
|
2016-07-17 15:41:53 +03:00
|
|
|
}
|
2016-07-18 21:16:56 +03:00
|
|
|
|
|
|
|
// MARK: - Private
|
2016-07-10 19:47:24 +03:00
|
|
|
private func addViews() {
|
|
|
|
self.window?.contentView?.addSubview(self.neoVimView)
|
|
|
|
self.neoVimView.autoPinEdgesToSuperviewEdges()
|
|
|
|
}
|
|
|
|
}
|