mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-09 11:26:41 +00:00
macos: setup undo responders at the AppDelegate level
This commit is contained in:
@@ -892,6 +892,14 @@ class AppDelegate: NSObject,
|
||||
NSApplication.shared.arrangeInFront(sender)
|
||||
}
|
||||
|
||||
@IBAction func undo(_ sender: Any?) {
|
||||
undoManager.undo()
|
||||
}
|
||||
|
||||
@IBAction func redo(_ sender: Any?) {
|
||||
undoManager.redo()
|
||||
}
|
||||
|
||||
private struct DerivedConfig {
|
||||
let initialWindow: Bool
|
||||
let shouldQuitAfterLastWindowClosed: Bool
|
||||
@@ -981,6 +989,22 @@ extension AppDelegate: NSMenuItemValidation {
|
||||
// terminal window (not quick terminal).
|
||||
return NSApp.keyWindow is TerminalWindow
|
||||
|
||||
case #selector(undo(_:)):
|
||||
if undoManager.canUndo {
|
||||
item.title = "Undo \(undoManager.undoActionName)"
|
||||
} else {
|
||||
item.title = "Undo"
|
||||
}
|
||||
return undoManager.canUndo
|
||||
|
||||
case #selector(redo(_:)):
|
||||
if undoManager.canRedo {
|
||||
item.title = "Redo \(undoManager.redoActionName)"
|
||||
} else {
|
||||
item.title = "Redo"
|
||||
}
|
||||
return undoManager.canRedo
|
||||
|
||||
default:
|
||||
return true
|
||||
}
|
||||
|
@@ -228,7 +228,7 @@ class TerminalManager {
|
||||
|
||||
// Ensure any publishers we have are cancelled
|
||||
w.closePublisher.cancel()
|
||||
|
||||
|
||||
// If we remove a window, we reset the cascade point to the key window so that
|
||||
// the next window cascade's from that one.
|
||||
if let focusedWindow = NSApplication.shared.keyWindow {
|
||||
|
Reference in New Issue
Block a user