macOS: hook up full action execution

This commit is contained in:
Mitchell Hashimoto
2025-04-21 09:40:02 -07:00
parent afd4ec6de2
commit 8bd91e7104
3 changed files with 13 additions and 2 deletions

View File

@ -47,7 +47,6 @@ struct CommandPaletteView: View {
var body: some View {
VStack(alignment: .leading, spacing: 0) {
// Prompt Field
CommandPaletteQuery(query: $query) { event in
switch (event) {
case .exit:

View File

@ -291,6 +291,15 @@ class BaseTerminalController: NSWindowController,
func zoomStateDidChange(to: Bool) {}
func performAction(_ action: String, on surfaceView: Ghostty.SurfaceView) {
guard let surface = surfaceView.surface else { return }
let len = action.utf8CString.count
if (len == 0) { return }
_ = action.withCString { cString in
ghostty_surface_binding_action(surface, cString, UInt(len - 1))
}
}
// MARK: Fullscreen
/// Toggle fullscreen for the given mode.

View File

@ -23,6 +23,9 @@ protocol TerminalViewDelegate: AnyObject {
/// This is called when a split is zoomed.
func zoomStateDidChange(to: Bool)
/// Perform an action. At the time of writing this is only triggered by the command palette.
func performAction(_ action: String, on: Ghostty.SurfaceView)
}
/// The view model is a required implementation for TerminalView callers. This contains
@ -141,7 +144,7 @@ struct TerminalView<ViewModel: TerminalViewModel>: View {
surfaceView: surfaceView,
isPresented: $viewModel.commandPaletteIsShowing,
ghosttyConfig: ghostty.config) { action in
print(action)
self.delegate?.performAction(action, on: surfaceView)
}
}
}