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

API ideas #9

Open
data-man opened this issue Aug 23, 2020 · 3 comments
Open

API ideas #9

data-man opened this issue Aug 23, 2020 · 3 comments

Comments

@data-man
Copy link
Contributor

  • implement format fn for Color and FontStyle types
  • with custom specifiers:
    if specifier is empty then write CSI-sequence
    bg & fg specifiers for Color type: treat value as background & foreground respectively
    np: don't write CSI prefix for intelligent updates

As result:

   debug.print("{fg} FG red {bg} BG green {} default", { .Red, .Green, .Reset });
@joachimschmidt557
Copy link
Member

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} });

@joachimschmidt557
Copy link
Member

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.

@joachimschmidt557
Copy link
Member

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 });

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

2 participants