macos: starting to work on new libghostty data models

This commit is contained in:
Mitchell Hashimoto
2025-06-19 07:07:32 -07:00
parent bbb69c8f27
commit 5259d0fa55
10 changed files with 171 additions and 46 deletions

View File

@@ -17,33 +17,19 @@ struct TerminalCommandPaletteView: View {
// The commands available to the command palette.
private var commandOptions: [CommandOption] {
guard let surface = surfaceView.surface else { return [] }
var ptr: UnsafeMutablePointer<ghostty_command_s>? = nil
var count: Int = 0
ghostty_surface_commands(surface, &ptr, &count)
guard let ptr else { return [] }
let buffer = UnsafeBufferPointer(start: ptr, count: count)
return Array(buffer).filter { c in
let key = String(cString: c.action_key)
switch (key) {
case "toggle_tab_overview",
"toggle_window_decorations",
"show_gtk_inspector":
return false
default:
return true
}
}.map { c in
let action = String(cString: c.action)
return CommandOption(
title: String(cString: c.title),
description: String(cString: c.description),
symbols: ghosttyConfig.keyboardShortcut(for: action)?.keyList
) {
onAction(action)
guard let surface = surfaceView.surfaceModel else { return [] }
do {
return try surface.commands().map { c in
return CommandOption(
title: c.title,
description: c.description,
symbols: ghosttyConfig.keyboardShortcut(for: c.action)?.keyList
) {
onAction(c.action)
}
}
} catch {
return []
}
}