macos: setup undo responders at the AppDelegate level
parent
6d32b01c64
commit
f571519157
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue