refactor: simplify load_entries in command and theme palette

This commit is contained in:
CJ van den Berg 2024-08-19 22:53:38 +02:00
parent 67ffff4caa
commit e83d9ea74d
2 changed files with 3 additions and 10 deletions

View file

@ -17,11 +17,7 @@ pub const Entry = struct {
pub fn load_entries(palette: *Type) !void { pub fn load_entries(palette: *Type) !void {
for (command.commands.items) |cmd_| if (cmd_) |p| { for (command.commands.items) |cmd_| if (cmd_) |p| {
(palette.entries.addOne() catch @panic("oom")).* = .{ (try palette.entries.addOne()).* = .{ .name = p.name, .id = p.id, .used_time = 0 };
.name = p.name,
.id = p.id,
.used_time = 0,
};
}; };
} }

View file

@ -22,11 +22,8 @@ pub const Match = struct {
var previous_theme: ?[]const u8 = null; var previous_theme: ?[]const u8 = null;
pub fn load_entries(palette: *Type) !void { pub fn load_entries(palette: *Type) !void {
previous_theme = tui.current().theme.name; previous_theme = tui.current().theme.name;
for (Widget.themes) |theme| { for (Widget.themes) |theme|
(palette.entries.addOne() catch @panic("oom")).* = .{ (try palette.entries.addOne()).* = .{ .name = theme.name };
.name = theme.name,
};
}
} }
pub fn add_menu_entry(palette: *Type, entry: *Entry, matches: ?[]const usize) !void { pub fn add_menu_entry(palette: *Type, entry: *Entry, matches: ?[]const usize) !void {