refactor: move hints out of generic palette

This commit is contained in:
CJ van den Berg 2024-12-10 20:08:43 +01:00
parent 8f3b8198e2
commit b3bd6d19b5
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
5 changed files with 31 additions and 15 deletions

View file

@ -23,7 +23,9 @@ pub const Match = struct {
};
var previous_theme: ?[]const u8 = null;
pub fn load_entries(palette: *Type) !void {
pub fn load_entries(palette: *Type) !usize {
var longest_hint: usize = 0;
var idx: usize = 0;
previous_theme = tui.current().theme.name;
for (Widget.themes) |theme| {
@ -35,7 +37,9 @@ pub fn load_entries(palette: *Type) !void {
if (previous_theme) |theme_name| if (std.mem.eql(u8, theme.name, theme_name)) {
palette.initial_selected = idx;
};
longest_hint = @max(longest_hint, theme.name.len);
}
return longest_hint;
}
pub fn add_menu_entry(palette: *Type, entry: *Entry, matches: ?[]const usize) !void {