mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-19 02:06:20 +03:00
macOS: hook up full action execution
This commit is contained in:
@ -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:
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user