macos: command palette entries support leading color

pull/9945/head
Mitchell Hashimoto 2025-12-17 08:56:21 -08:00
parent c84113d199
commit 7e46200d31
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
2 changed files with 10 additions and 1 deletions

View File

@ -6,6 +6,7 @@ struct CommandOption: Identifiable, Hashable {
let description: String?
let symbols: [String]?
let leadingIcon: String?
let leadingColor: Color?
let badge: String?
let emphasis: Bool
let action: () -> Void
@ -15,6 +16,7 @@ struct CommandOption: Identifiable, Hashable {
description: String? = nil,
symbols: [String]? = nil,
leadingIcon: String? = nil,
leadingColor: Color? = nil,
badge: String? = nil,
emphasis: Bool = false,
action: @escaping () -> Void
@ -23,6 +25,7 @@ struct CommandOption: Identifiable, Hashable {
self.description = description
self.symbols = symbols
self.leadingIcon = leadingIcon
self.leadingColor = leadingColor
self.badge = badge
self.emphasis = emphasis
self.action = action
@ -283,6 +286,12 @@ fileprivate struct CommandRow: View {
var body: some View {
Button(action: action) {
HStack(spacing: 8) {
if let color = option.leadingColor {
Circle()
.fill(color)
.frame(width: 8, height: 8)
}
if let icon = option.leadingIcon {
Image(systemName: icon)
.foregroundStyle(option.emphasis ? Color.accentColor : .secondary)

View File

@ -62,7 +62,7 @@ struct TerminalCommandPaletteView: View {
return CommandOption(
title: c.title,
description: c.description,
symbols: ghosttyConfig.keyboardShortcut(for: c.action)?.keyList
symbols: ghosttyConfig.keyboardShortcut(for: c.action)?.keyList,
) {
onAction(c.action)
}