mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-14 19:45:49 +00:00
Add a `surface configuration` record type to the scripting dictionary, implement `new surface configuration` (with optional copy-from), and allow `new window` to accept `with configuration`.
30 lines
962 B
Swift
30 lines
962 B
Swift
import Cocoa
|
|
|
|
/// Protocol to more easily implement AppleScript records in Swift.
|
|
protocol ScriptRecord {
|
|
/// Initialize a default record.
|
|
init()
|
|
|
|
/// Initialize a record from the raw value from AppleScript.
|
|
init(scriptRecord: NSDictionary?) throws
|
|
|
|
/// Encode into the dictionary form for AppleScript.
|
|
var dictionaryRepresentation: NSDictionary { get }
|
|
}
|
|
|
|
/// An error that can be thrown by `ScriptRecord.init(scriptRecord:)`. Any localized error
|
|
/// can be thrown but this is a common one.
|
|
enum RecordParseError: LocalizedError {
|
|
case invalidType(parameter: String, expected: String)
|
|
case invalidValue(parameter: String, message: String)
|
|
|
|
var errorDescription: String? {
|
|
switch self {
|
|
case .invalidType(let parameter, let expected):
|
|
return "\(parameter) must be \(expected)."
|
|
case .invalidValue(let parameter, let message):
|
|
return "\(parameter) \(message)."
|
|
}
|
|
}
|
|
}
|