mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-27 21:48:38 +00:00
macos: invoke keybind intent
This commit is contained in:
32
macos/Sources/Features/App Intents/KeybindIntent.swift
Normal file
32
macos/Sources/Features/App Intents/KeybindIntent.swift
Normal file
@@ -0,0 +1,32 @@
|
||||
import AppKit
|
||||
import AppIntents
|
||||
|
||||
/// App intent that invokes a command palette entry.
|
||||
struct KeybindIntent: AppIntent {
|
||||
static var title: LocalizedStringResource = "Invoke a Keybind Action"
|
||||
|
||||
@Parameter(
|
||||
title: "Terminal",
|
||||
description: "The terminal to base available commands from."
|
||||
)
|
||||
var terminal: TerminalEntity
|
||||
|
||||
@Parameter(
|
||||
title: "Action",
|
||||
description: "The keybind action to invoke. This can be any valid keybind action you could put in a configuration file."
|
||||
)
|
||||
var action: String
|
||||
|
||||
@available(macOS 26.0, *)
|
||||
static var supportedModes: IntentModes = [.background, .foreground]
|
||||
|
||||
@MainActor
|
||||
func perform() async throws -> some IntentResult & ReturnsValue<Bool> {
|
||||
guard let surface = terminal.surfaceModel else {
|
||||
throw GhosttyIntentError.surfaceNotFound
|
||||
}
|
||||
|
||||
let performed = surface.perform(action: action)
|
||||
return .result(value: performed)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user