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_black(string: String) -> String

Set background color to black.

pub fn bg_blue(string: String) -> String

Set background color to blue.

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_cyan(string: String) -> String

Set background color to cyan.

pub fn bg_gray(string: String) -> String

Set background color to gray.

pub fn bg_green(string: String) -> String

Set background color to green.

pub fn bg_magenta(string: String) -> String

Set background color to magenta.

pub fn bg_red(string: String) -> String

Set background color to red.

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 bg_yellow(string: String) -> String

Set background color to yellow.

pub fn black(string: String) -> String

Set text color to black.

pub fn bleed(string: String) -> String

Propagate style from this string until next reset. Must be the last function in the pipeline.

pub fn blue(string: String) -> String

Set text color to blue.

pub fn bold(string: String) -> String

Set text style to bold

pub fn bright_blue(string: String) -> String

Set text color to a lighter blue.

pub fn bright_cyan(string: String) -> String

Set text color to a lighter cyan.

pub fn bright_green(string: String) -> String

Set text color to a lighter green.

pub fn bright_magenta(string: String) -> String

Set text color to a lighter magenta.

pub fn bright_red(string: String) -> String

Set text color to a lighter red.

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 cyan(string: String) -> String

Set text color to cyan.

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 gray(string: String) -> String

Set text color to gray.

pub fn green(string: String) -> String

Set text color to green.

pub fn italic(string: String) -> String

Set text style to italic

pub fn magenta(string: String) -> String

Set text color to magenta.

pub fn offset_rainbow(string: String, offset: Int) -> String

Rainbow text with an integer offset

pub fn rainbow(string: String) -> String
pub fn red(string: String) -> String

Set text color to red.

pub fn underline(string: String) -> String

Set text style to underlined

pub fn white(string: String) -> String

Set text color to an off-white color, for a lighter white try bright_white

pub fn yellow(string: String) -> String

Set text color to yellow.

Search Document