Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom format function #31

Open
illfygli opened this issue Jan 11, 2024 · 0 comments
Open

custom format function #31

illfygli opened this issue Jan 11, 2024 · 0 comments

Comments

@illfygli
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant