Skip to content

custom format function #31

@illfygli

Description

@illfygli

Do you think it would make sense to include a format function, so that Styles can be printed directly?

I added this,

pub fn format(value: Self, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) std.os.WriteError!void {
    try @import("format.zig").updateStyle(writer, value, null);
}

while porting a program away from a different lib, where I had added something similar, and it made the port easy, if suboptimal.

And another thing, when you don't want the cursor to be misplaced, you need yet more escape codes around the bytes that aren't displayed. Currently I have a wrapping writer that adds them as neccessary, but maybe that should be part of the lib in some way?

Would be happy to send patches for those things.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions