From fd5ad1f574e3ad084db0e2a9b2161edaf53e85e5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 5 Mar 2026 21:03:45 -0800 Subject: [PATCH] macos: add AppleScript commands for text input, key, and mouse events 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). --- macos/Ghostty.sdef | 92 ++++++++++++++++++ .../Ghostty.Input.Mods+AppleScript.swift | 18 ++++ .../AppleScript/ScriptInputTextCommand.swift | 39 ++++++++ .../AppleScript/ScriptKeyEventCommand.swift | 74 +++++++++++++++ .../ScriptMouseButtonCommand.swift | 93 +++++++++++++++++++ .../AppleScript/ScriptMousePosCommand.swift | 63 +++++++++++++ .../ScriptMouseScrollCommand.swift | 69 ++++++++++++++ 7 files changed, 448 insertions(+) create mode 100644 macos/Sources/Features/AppleScript/Ghostty.Input.Mods+AppleScript.swift create mode 100644 macos/Sources/Features/AppleScript/ScriptInputTextCommand.swift create mode 100644 macos/Sources/Features/AppleScript/ScriptKeyEventCommand.swift create mode 100644 macos/Sources/Features/AppleScript/ScriptMouseButtonCommand.swift create mode 100644 macos/Sources/Features/AppleScript/ScriptMousePosCommand.swift create mode 100644 macos/Sources/Features/AppleScript/ScriptMouseScrollCommand.swift diff --git a/macos/Ghostty.sdef b/macos/Ghostty.sdef index 2c27a861f..ba959fe01 100644 --- a/macos/Ghostty.sdef +++ b/macos/Ghostty.sdef @@ -58,6 +58,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +