ansi-term
ansi-term copied to clipboard
API ideas
- implement
formatfn forColorandFontStyletypes - with custom specifiers:
if specifier is empty then write CSI-sequence
bg&fgspecifiers for Color type: treat value as background & foreground respectivelynp: don't write CSI prefix for intelligent updates
As result:
debug.print("{fg} FG red {bg} BG green {} default", { .Red, .Green, .Reset });
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 });