mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-27 21:48:38 +00:00
macos: intent to open quick terminal
This commit is contained in:
28
macos/Sources/Features/App Intents/QuickTerminalIntent.swift
Normal file
28
macos/Sources/Features/App Intents/QuickTerminalIntent.swift
Normal file
@@ -0,0 +1,28 @@
|
||||
import AppKit
|
||||
import AppIntents
|
||||
|
||||
struct QuickTerminalIntent: AppIntent {
|
||||
static var title: LocalizedStringResource = "Open the Quick Terminal"
|
||||
static var description = IntentDescription("Open the Quick Terminal. If it is already open, then do nothing.")
|
||||
|
||||
@available(macOS 26.0, *)
|
||||
static var supportedModes: IntentModes = .background
|
||||
|
||||
@MainActor
|
||||
func perform() async throws -> some IntentResult & ReturnsValue<[TerminalEntity]> {
|
||||
guard let delegate = NSApp.delegate as? AppDelegate else {
|
||||
throw GhosttyIntentError.appUnavailable
|
||||
}
|
||||
|
||||
// This is safe to call even if it is already shown.
|
||||
let c = delegate.quickController
|
||||
c.animateIn()
|
||||
|
||||
// Grab all our terminals
|
||||
let terminals = c.surfaceTree.root?.leaves().map {
|
||||
TerminalEntity($0)
|
||||
} ?? []
|
||||
|
||||
return .result(value: terminals)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user