Open data-man opened 4 years ago
Counter-proposal which works with #10 as well:
std.debug.print("this is normal text {this is also normal} {this is red}", .{ Style.default, Style{.foreground = Color.red} });
This is of course convenient for enabling applications to have colored terminal output. But I think this library should also be robust and still provide the low-level interfaces like updateStyle
in order to minimize the bytes written to the terminal.
Another counter-proposal: I think the most common use case for this high-level printing would be in association with compile-time known styles. This means we can design a function
pub fn red(comptime text: []const u8) []const u8
and use this for example:
std.debug.print("{}: " ++ Styled.red("Path {} does not exist"), .{ time(), path });
format
fn forColor
andFontStyle
typesbg
&fg
specifiers for Color type: treat value as background & foreground respectivelynp
: don't write CSI prefix for intelligent updatesAs result: