mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-10 03:46:34 +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)
|
NSApplication.shared.arrangeInFront(sender)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IBAction func undo(_ sender: Any?) {
|
||||||
|
undoManager.undo()
|
||||||
|
}
|
||||||
|
|
||||||
|
@IBAction func redo(_ sender: Any?) {
|
||||||
|
undoManager.redo()
|
||||||
|
}
|
||||||
|
|
||||||
private struct DerivedConfig {
|
private struct DerivedConfig {
|
||||||
let initialWindow: Bool
|
let initialWindow: Bool
|
||||||
let shouldQuitAfterLastWindowClosed: Bool
|
let shouldQuitAfterLastWindowClosed: Bool
|
||||||
@@ -981,6 +989,22 @@ extension AppDelegate: NSMenuItemValidation {
|
|||||||
// terminal window (not quick terminal).
|
// terminal window (not quick terminal).
|
||||||
return NSApp.keyWindow is TerminalWindow
|
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:
|
default:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user