diff --git a/macos/Sources/Features/Command Palette/CommandPalette.swift b/macos/Sources/Features/Command Palette/CommandPalette.swift index 71fc7ae4d..33b97585a 100644 --- a/macos/Sources/Features/Command Palette/CommandPalette.swift +++ b/macos/Sources/Features/Command Palette/CommandPalette.swift @@ -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: diff --git a/macos/Sources/Features/Terminal/BaseTerminalController.swift b/macos/Sources/Features/Terminal/BaseTerminalController.swift index b9a1def1b..d4e7dfb45 100644 --- a/macos/Sources/Features/Terminal/BaseTerminalController.swift +++ b/macos/Sources/Features/Terminal/BaseTerminalController.swift @@ -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. diff --git a/macos/Sources/Features/Terminal/TerminalView.swift b/macos/Sources/Features/Terminal/TerminalView.swift index e3c4f04b7..1bc0603a9 100644 --- a/macos/Sources/Features/Terminal/TerminalView.swift +++ b/macos/Sources/Features/Terminal/TerminalView.swift @@ -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: View { surfaceView: surfaceView, isPresented: $viewModel.commandPaletteIsShowing, ghosttyConfig: ghostty.config) { action in - print(action) + self.delegate?.performAction(action, on: surfaceView) } } }