feat: add icon in file type palette
This commit is contained in:
parent
3f61e46dfe
commit
5294ace5da
1 changed files with 6 additions and 5 deletions
|
@ -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_))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue