feat: add icon in file type palette

This commit is contained in:
CJ van den Berg 2025-08-13 17:35:42 +02:00
parent 3f61e46dfe
commit 5294ace5da
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -14,6 +14,7 @@ pub fn Variant(comptime command: []const u8, comptime label_: []const u8, allow_
pub const label = label_;
pub const name = " file type";
pub const description = "file type";
pub const icon = "";
pub const Entry = struct {
label: []const u8,
@ -88,13 +89,13 @@ pub fn Variant(comptime command: []const u8, comptime label_: []const u8, allow_
var iter = button.opts.label;
var description_: []const u8 = undefined;
var icon: []const u8 = undefined;
var icon_: []const u8 = undefined;
var color: u24 = undefined;
if (!(cbor.matchString(&iter, &description_) catch false)) @panic("invalid file_type description");
if (!(cbor.matchString(&iter, &icon) catch false)) @panic("invalid file_type icon");
if (!(cbor.matchString(&iter, &icon_) catch false)) @panic("invalid file_type icon");
if (!(cbor.matchInt(u24, &iter, &color) catch false)) @panic("invalid file_type color");
tui.render_file_icon(&button.plane, icon, color);
tui.render_file_icon(&button.plane, icon_, color);
button.plane.set_style(style_label);
_ = button.plane.print("{s} ", .{description_}) catch {};
@ -117,12 +118,12 @@ pub fn Variant(comptime command: []const u8, comptime label_: []const u8, allow_
fn select(menu: **Type.MenuState, button: *Type.ButtonState) void {
var description_: []const u8 = undefined;
var icon: []const u8 = undefined;
var icon_: []const u8 = undefined;
var color: u24 = undefined;
var name_: []const u8 = undefined;
var iter = button.opts.label;
if (!(cbor.matchString(&iter, &description_) catch false)) return;
if (!(cbor.matchString(&iter, &icon) catch false)) return;
if (!(cbor.matchString(&iter, &icon_) catch false)) return;
if (!(cbor.matchInt(u24, &iter, &color) catch false)) return;
if (!(cbor.matchString(&iter, &name_) catch false)) return;
if (!allow_previous) if (previous_file_type) |prev| if (std.mem.eql(u8, prev, name_))