chromatic
Chromatic
Composable text formatting for CLI in Gleam.
Usage
The best way to use this is through Gleam’s pipelines.
Check it out!
import chromatic.{bold, italic, magenta, rainbow}
pub fn main() {
io.println(
"Hello "
<> "Gleam"
|> magenta
|> italic
|> bold
<> ", this is "
<> "Chromatic"
|> rainbow
|> bold,
)
}
Functions
pub fn bg_bright_blue(string: String) -> String
Set background color to a lighter blue.
pub fn bg_bright_cyan(string: String) -> String
Set background color to a lighter cyan.
pub fn bg_bright_green(string: String) -> String
Set background color to a lighter green.
pub fn bg_bright_magenta(string: String) -> String
Set background color to a lighter magenta.
pub fn bg_bright_red(string: String) -> String
Set background color to a lighter red.
pub fn bg_bright_white(string: String) -> String
Set background color to a bright white color
pub fn bg_bright_yellow(string: String) -> String
Set background color to a lighter yellow.
pub fn bg_white(string: String) -> String
Set’s background to an off-white color,
for a lighter white try bg_bright_white
pub fn bleed(string: String) -> String
Propagate style from this string until next reset. Must be the last function in the pipeline.
pub fn bright_magenta(string: String) -> String
Set text color to a lighter magenta.
pub fn bright_white(string: String) -> String
Set text color to a bright white color
pub fn bright_yellow(string: String) -> String
Set text color to a lighter yellow.
pub fn clear(string: String) -> String
Clears any previously added styles that would have bled into it.
Only necessary if you’ve used bleed.
Like bleed needs to be the last function in the pipeline
pub fn clear_str() -> String
Print this to clear any styles that are bleeding through.
pub fn decorate_ansi(string: String, code: String) -> String
ANSI escape helper, adds a ANSI code to the provided string. This also terminates the string with the clear sequence so it doesn’t affect other strings.
pub fn decorate_ansi_raw(string: String, code: String) -> String
ANSI escape helper, adds a ANSI code to the provided string.
Unlike the decorate_ansi function not terminate with the clear sequence.
pub fn offset_rainbow(string: String, offset: Int) -> String
Rainbow text with an integer offset
pub fn white(string: String) -> String
Set text color to an off-white color,
for a lighter white try bright_white