mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-14 11:35:48 +00:00
Add five new AppleScript commands to Ghostty.sdef mirroring the existing App Intents for terminal input: - `input text`: send text to a terminal as if pasted - `send key`: simulate a keyboard event with optional action and modifiers - `send mouse button`: send a mouse button press/release event - `send mouse position`: send a mouse cursor position event - `send mouse scroll`: send a scroll event with precision and momentum A shared `input action` enumeration (press/release) is used by both key and mouse button commands. Modifier keys are passed as a comma-separated string parameter (shift, control, option, command).
19 lines
673 B
Swift
19 lines
673 B
Swift
extension Ghostty.Input.Mods {
|
|
/// Parses a comma-separated modifier string into `Ghostty.Input.Mods`.
|
|
///
|
|
/// Recognized names: `shift`, `control`, `option`, `command`.
|
|
/// Returns `nil` if any unrecognized modifier name is encountered.
|
|
init?(scriptModifiers string: String) {
|
|
self = []
|
|
for part in string.split(separator: ",") {
|
|
switch part.trimmingCharacters(in: .whitespaces).lowercased() {
|
|
case "shift": insert(.shift)
|
|
case "control": insert(.ctrl)
|
|
case "option": insert(.alt)
|
|
case "command": insert(.super)
|
|
default: return nil
|
|
}
|
|
}
|
|
}
|
|
}
|