This commit is contained in:
Mitchell Hashimoto
2025-04-21 10:50:34 -07:00
parent e33eed0216
commit a732bb272d
2 changed files with 3 additions and 15 deletions

View File

@@ -13,24 +13,12 @@ struct CommandOption: Identifiable, Hashable {
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
// Sample data remains the same
static let sampleData: [CommandOption] = [
.init(title: "assistant: copy code", shortcut: nil, action: {}),
.init(title: "assistant: inline assist", shortcut: "⌃⏎", action: {}),
.init(title: "assistant: insert into editor", shortcut: "⌘<", action: {}),
.init(title: "assistant: new chat", shortcut: nil, action: {}),
.init(title: "assistant: open prompt library", shortcut: nil, action: {}),
.init(title: "assistant: quote selection", shortcut: "⌘>", action: {}),
.init(title: "assistant: show configuration", shortcut: nil, action: {}),
.init(title: "assistant: toggle focus", shortcut: "⌘?", action: {}),
]
}
struct CommandPaletteView: View {
@Binding var isPresented: Bool
var backgroundColor: Color = Color(nsColor: .windowBackgroundColor)
var options: [CommandOption] = CommandOption.sampleData
var options: [CommandOption]
@State private var query = ""
@State private var selectedIndex: UInt = 0
@State private var hoveredOptionID: UUID? = nil
@@ -158,7 +146,7 @@ fileprivate struct CommandPaletteQuery: View {
}
fileprivate struct CommandTable: View {
var options: [CommandOption] = CommandOption.sampleData
var options: [CommandOption]
@Binding var selectedIndex: UInt
@Binding var hoveredOptionID: UUID?
var action: (CommandOption) -> Void

View File

@@ -2,7 +2,7 @@ const std = @import("std");
const builtin = @import("builtin");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const Action = @import("binding.zig").Action;
const Action = @import("Binding.zig").Action;
/// A command is a named binding action that can be executed from
/// something like a command palette.