1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 11:37:32 +03:00
vimr/VimR/AppDelegate.swift

61 lines
1.6 KiB
Swift
Raw Normal View History

/**
* Tae Won Ha - http://taewon.de - @hataewon
* See LICENSE
*/
2016-06-03 23:13:59 +03:00
import Cocoa
import RxSwift
import PureLayout
2016-06-03 23:13:59 +03:00
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
2016-06-03 23:13:59 +03:00
2016-07-26 22:42:30 +03:00
private let prefStore = PrefStore(source: Observable.empty())
2016-07-24 21:32:07 +03:00
private let mainWindowManager: MainWindowManager
2016-07-26 22:42:30 +03:00
private let prefWindowComponent = PrefWindowComponent(source: Observable.empty())
override init() {
self.mainWindowManager = MainWindowManager(prefWindowComponent: self.prefWindowComponent)
super.init()
}
2016-07-24 21:32:07 +03:00
@IBAction func debugSomething(sender: AnyObject!) {
NSLog("debug sth...")
}
@IBAction func newDocument(sender: AnyObject!) {
self.mainWindowManager.newMainWindow()
}
2016-07-24 21:32:07 +03:00
@IBAction func showPrefWindow(sender: AnyObject!) {
self.prefWindowComponent.show()
}
func applicationDidFinishLaunching(aNotification: NSNotification) {
// let testView = InputTestView(frame: CGRect(x: 0, y: 0, width: 300, height: 300))
// self.window.contentView?.addSubview(testView)
// self.window.makeFirstResponder(testView)
self.newDocument(self)
}
func applicationShouldTerminate(sender: NSApplication) -> NSApplicationTerminateReply {
if self.mainWindowManager.hasDirtyWindows() {
let alert = NSAlert()
alert.addButtonWithTitle("Cancel")
alert.addButtonWithTitle("Discard and Quit")
alert.messageText = "There are windows with unsaved buffers!"
alert.alertStyle = .WarningAlertStyle
if alert.runModal() == NSAlertSecondButtonReturn {
return .TerminateNow
}
return .TerminateCancel
}
return .TerminateNow
}
2016-06-03 23:13:59 +03:00
}