config: add command-palette-entry config option

This commit is contained in:
Leah Amelia Chen
2025-06-25 18:49:57 +02:00
committed by Mitchell Hashimoto
parent d419e5c922
commit dbe6035da0
3 changed files with 177 additions and 2 deletions

View File

@@ -18,7 +18,7 @@ const Action = @import("Binding.zig").Action;
pub const Command = struct {
action: Action,
title: [:0]const u8,
description: [:0]const u8,
description: [:0]const u8 = "",
/// ghostty_command_s
pub const C = extern struct {
@@ -28,6 +28,21 @@ pub const Command = struct {
description: [*:0]const u8,
};
pub fn clone(self: *const Command, alloc: Allocator) Allocator.Error!Command {
return .{
.action = try self.action.clone(alloc),
.title = try alloc.dupeZ(u8, self.title),
.description = try alloc.dupeZ(u8, self.description),
};
}
pub fn equal(self: Command, other: Command) bool {
if (self.action.hash() != other.action.hash()) return false;
if (!std.mem.eql(u8, self.title, other.title)) return false;
if (!std.mem.eql(u8, self.description, other.description)) return false;
return true;
}
/// Convert this command to a C struct.
pub fn comptimeCval(self: Command) C {
assert(@inComptime());