macos: Add AppleScript commands for window and tab control

Add scripting dictionary commands for activating windows, selecting tabs,
closing tabs, and closing windows.

Implement the corresponding Cocoa AppleScript command handlers and expose
minimal ScriptWindow/ScriptTab helpers needed to resolve live targets.

Verified by building Ghostty and running osascript commands against the
absolute Debug app path to exercise all four new commands.
This commit is contained in:
Mitchell Hashimoto
2026-03-06 14:31:03 -08:00
parent d271c8ccaa
commit 28b4e2495d
5 changed files with 149 additions and 0 deletions

View File

@@ -63,6 +63,16 @@ final class ScriptTab: NSObject {
return window?.tabIsSelected(controller) ?? false
}
/// Best-effort native window containing this tab.
var parentWindow: NSWindow? {
controller?.window
}
/// Live controller backing this tab wrapper.
var parentController: BaseTerminalController? {
controller
}
/// Exposed as the AppleScript `terminals` element on a tab.
///
/// Returns all terminal surfaces (split panes) within this tab.