DVUI

format

Parameters

#
self:*const Keybind
*const Keybind
_:[]const u8
[]const u8
_:std.fmt.FormatOptions
std.fmt.FormatOptions
writer:anytype
anytype

Source

Implementation

#
pub fn format(self: *const Keybind, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
        var needs_space = false;
        if (self.control) |ctrl| {
            if (needs_space) try writer.writeByte(' ') else needs_space = true;
            if (!ctrl) try writer.writeByte('!');
            try writer.writeAll("ctrl");
        }

        if (self.command) |cmd| {
            if (needs_space) try writer.writeByte(' ') else needs_space = true;
            if (!cmd) try writer.writeByte('!');
            try writer.writeAll("cmd");
        }

        if (self.alt) |alt| {
            if (needs_space) try writer.writeByte(' ') else needs_space = true;
            if (!alt) try writer.writeByte('!');
            try writer.writeAll("alt");
        }

        if (self.shift) |shift| {
            if (needs_space) try writer.writeByte(' ') else needs_space = true;
            if (!shift) try writer.writeByte('!');
            try writer.writeAll("shift");
        }

        if (self.key) |key| {
            if (needs_space) try writer.writeByte(' ') else needs_space = true;
            try writer.writeAll(@tagName(key));
        }
    }