diff --git a/phpmon/AppDelegate.swift b/phpmon/AppDelegate.swift index 666452c..bfb90c4 100644 --- a/phpmon/AppDelegate.swift +++ b/phpmon/AppDelegate.swift @@ -107,16 +107,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { // MARK: - Callable via Obj-C (#selector) @objc func openOutput() { - if (App.shared.windowController == nil) { - let vc = NSStoryboard(name: "Main", bundle: nil).instantiateController(withIdentifier: "logWindow") as! LogViewController - Shell.shared.delegate = vc - let window = NSWindow(contentViewController: vc) - window.title = "Terminal Output" - window.delegate = self - App.shared.windowController = NSWindowController(window: window) - } - App.shared.windowController!.showWindow(self) - NSApp.activate(ignoringOtherApps: true) + LogViewController.show(delegate: self) } @objc func updatePhpVersionInStatusBar() { diff --git a/phpmon/View Controllers/LogViewController.swift b/phpmon/View Controllers/LogViewController.swift index 73be213..f67a9ff 100644 --- a/phpmon/View Controllers/LogViewController.swift +++ b/phpmon/View Controllers/LogViewController.swift @@ -10,6 +10,19 @@ import Cocoa class LogViewController: NSViewController, ShellDelegate { + public static func show(delegate: NSWindowDelegate? = nil) { + if (App.shared.windowController == nil) { + let vc = NSStoryboard(name: "Main", bundle: nil).instantiateController(withIdentifier: "logWindow") as! LogViewController + Shell.shared.delegate = vc + let window = NSWindow(contentViewController: vc) + window.title = "Terminal Output" + window.delegate = delegate + App.shared.windowController = NSWindowController(window: window) + } + App.shared.windowController!.showWindow(self) + NSApp.activate(ignoringOtherApps: true) + } + @IBOutlet var textView: NSTextView! public func appendHistoryItem(_ historyItem: ShellHistoryItem) {