mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-22 19:18:36 +00:00
macos: confirm on quit
This commit is contained in:
@@ -18,15 +18,7 @@ struct GhosttyApp: App {
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
switch ghostty.readiness {
|
||||
case .loading:
|
||||
Text("Loading")
|
||||
case .error:
|
||||
ErrorView()
|
||||
case .ready:
|
||||
Ghostty.TerminalSplit(onClose: Self.closeWindow)
|
||||
.ghosttyApp(ghostty.app!)
|
||||
}
|
||||
ContentView(ghostty: ghostty)
|
||||
}
|
||||
.backport.defaultSize(width: 800, height: 600)
|
||||
.commands {
|
||||
@@ -110,7 +102,9 @@ struct GhosttyApp: App {
|
||||
}
|
||||
}
|
||||
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
class AppDelegate: NSObject, NSApplicationDelegate, ObservableObject {
|
||||
@Published var confirmQuit: Bool = false
|
||||
|
||||
// See CursedMenuManager for more information.
|
||||
private var menuManager: CursedMenuManager?
|
||||
|
||||
@@ -124,6 +118,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
// we can't create from SwiftUI.
|
||||
menuManager = CursedMenuManager()
|
||||
}
|
||||
|
||||
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
|
||||
confirmQuit = true
|
||||
return .terminateLater
|
||||
}
|
||||
}
|
||||
|
||||
/// SwiftUI as of macOS 13.x provides no way to manage the default menu items that are created
|
||||
|
Reference in New Issue
Block a user