macos: expose name (title) on window, tab, and terminal via AppleScript

Add a `name` property (code `pnam`, cocoa key `title`) to the window, tab,
and terminal classes in the scripting definition. This follows the standard
Cocoa scripting convention where `name`/`pnam` maps to the `title` KVC key,
matching what Apple does in CocoaStandard.sdef for NSWindow.

Also fixes the pre-existing terminal `title` property which used a custom
four-char code (`Gttl`) that AppleScript could not resolve directly — only
via `properties of terminal`. All three classes now use the standard `pnam`
code so `name of window 1`, `name of tab 1 of window 1`, and
`name of terminal 1` all work correctly.
This commit is contained in:
Mitchell Hashimoto
2026-03-06 08:11:56 -08:00
parent e514035519
commit 122d0ecdfd
3 changed files with 25 additions and 1 deletions

View File

@@ -37,6 +37,14 @@ final class ScriptTab: NSObject {
stableID
}
/// Exposed as the AppleScript `title` property.
///
/// Returns the title of the tab's window.
@objc(title)
var title: String {
controller?.window?.title ?? ""
}
/// Exposed as the AppleScript `index` property.
///
/// Cocoa scripting expects this to be 1-based for user-facing collections.