macos: add AppleScript front window and focused terminal properties

This adds two new propeties to make it easy to get the frontmost (main)
window and the focused terminal within a tab. We already had a property
to get the selected tab of a tab group.
This commit is contained in:
Mitchell Hashimoto
2026-03-08 19:53:18 -07:00
parent 2d347cad33
commit 233fb12081
3 changed files with 30 additions and 0 deletions

View File

@@ -57,6 +57,16 @@ extension NSApplication {
return result
}
/// Exposed as the AppleScript `front window` property.
///
/// `scriptWindows` is already ordered front-to-back, so the first item is
/// the frontmost logical Ghostty window.
@objc(frontWindow)
var frontWindow: ScriptWindow? {
guard isAppleScriptEnabled else { return nil }
return scriptWindows.first
}
/// Enables AppleScript unique-ID lookup for window references.
///
/// Required selector name pattern for element key `scriptWindows`: