Skip to content
This repository has been archived by the owner on Oct 8, 2022. It is now read-only.

CLI-like output #67

Closed
vladdeSV opened this issue Dec 24, 2020 · 4 comments
Closed

CLI-like output #67

vladdeSV opened this issue Dec 24, 2020 · 4 comments
Labels
feature Request for a new feature
Projects

Comments

@vladdeSV
Copy link
Owner

vladdeSV commented Dec 24, 2020

Enable colors with std.stdio's write family.

I tried implementing a feature like this once by overriding the toString() method for the TextStyle struct, which outputs as an ANSI escape code which sets the colors. This functionality, however, does not belong there.

One approach would be to add a function with the signature

string cli(TextStyle style);

where you could do the following in the standard writeln

writeln("Welcome ", TextStyle().bg(Color.yellow).cli(), "user", TextStyle().cli(), ".");

// alternatively
auto info = TextStyle().bg(Color.yellow).cli();
auto reset = TextStyle().fg(Color.initial).bg(Color.initial).cli();
writeln("Welcome ", info, "user", reset, ".");
@vladdeSV vladdeSV added the feature Request for a new feature label Dec 24, 2020
@vladdeSV vladdeSV added this to TODO: in scone via automation Dec 24, 2020
@vladdeSV
Copy link
Owner Author

Alternatively, another approach could be to add completely new function, for example scone.writeln(...) which converts each argument which is a TextStyle to a string and calls the appropriate write function within itself.

@vladdeSV
Copy link
Owner Author

This would mean I could deprecate my own small project termcolor-d.

@vladdeSV
Copy link
Owner Author

This was implemented in a3896c7.

scone automation moved this from TODO: to DONE: Jan 17, 2021
@vladdeSV
Copy link
Owner Author

Windows Terminal can handle RGB color output, but RGB in colors are disabled in Color.

This causes some conflict, and might be related to #66.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Request for a new feature
Projects
scone
DONE:
Development

No branches or pull requests

1 participant