mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-01-08 22:33:20 +00:00
macOS: command-palette-entry is now visible in macOS
This commit is contained in:
@@ -64,7 +64,7 @@ struct TerminalCommandPaletteView: View {
|
||||
// Sort the rest. We replace ":" with a character that sorts before space
|
||||
// so that "Foo:" sorts before "Foo Bar:". Use sortKey as a tie-breaker
|
||||
// for stable ordering when titles are equal.
|
||||
options.append(contentsOf: (jumpOptions + terminalOptions).sorted { a, b in
|
||||
options.append(contentsOf: (jumpOptions + terminalOptions + customEntries).sorted { a, b in
|
||||
let aNormalized = a.title.replacingOccurrences(of: ":", with: "\t")
|
||||
let bNormalized = b.title.replacingOccurrences(of: ":", with: "\t")
|
||||
let comparison = aNormalized.localizedCaseInsensitiveCompare(bNormalized)
|
||||
@@ -135,6 +135,19 @@ struct TerminalCommandPaletteView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// Custom commands from the command-palette-entry configuration.
|
||||
private var customEntries: [CommandOption] {
|
||||
guard let appDelegate = NSApp.delegate as? AppDelegate else { return [] }
|
||||
return appDelegate.ghostty.config.commandPaletteEntries.map { c in
|
||||
CommandOption(
|
||||
title: c.title,
|
||||
description: c.description
|
||||
) {
|
||||
onAction(c.action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Commands for jumping to other terminal surfaces.
|
||||
private var jumpOptions: [CommandOption] {
|
||||
TerminalController.all.flatMap { controller -> [CommandOption] in
|
||||
|
||||
@@ -622,6 +622,16 @@ extension Ghostty {
|
||||
let str = String(cString: ptr)
|
||||
return Scrollbar(rawValue: str) ?? defaultValue
|
||||
}
|
||||
|
||||
var commandPaletteEntries: [Ghostty.Command] {
|
||||
guard let config = self.config else { return [] }
|
||||
var v: ghostty_config_command_list_s = .init()
|
||||
let key = "command-palette-entry"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.lengthOfBytes(using: .utf8))) else { return [] }
|
||||
guard v.len > 0 else { return [] }
|
||||
let buffer = UnsafeBufferPointer(start: v.commands, count: v.len)
|
||||
return buffer.map { Ghostty.Command(cValue: $0) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user