dahlia

Types

pub type Dahlia {
  Dahlia(
    colors: Option(map.Map(String, Ansi)),
    escape_character: String,
  )
}

Constructors

  • Dahlia(
      colors: Option(map.Map(String, Ansi)),
      escape_character: String,
    )

Functions

pub fn convert(d: Dahlia, string str: String) -> String

Convert a string to a formatted string.

let result = dahlia.new()
  |> dahlia.convert("&aABCD")
io.println(result)
pub fn main() -> Dahlia
pub fn merge_colors(d: Dahlia, colors: Map(String, Ansi)) -> Dahlia

Merge colors to the current color set for the dahlia object.

import dahlia
import dahlia/ansi
import gleam/map

fn main() {
  dahlia.new()
  |> dahlia.merge_colors(
    map.new()
    |> map.insert("c", ansi.Ansi24(255, 175, 243))
  )
  |> dahlia.print("&cHello Wolrd")
}
pub fn new() -> Dahlia

Create a new dahlia object.

pub fn print(d: Dahlia, string str: String) -> Dahlia

Print a string as a formatted string and return the Dahlia object.

dahlia.new()
  |> dahlia.print("&aHello Wolrd")
  |> dahlia.print("&aSomething else")
pub fn println(d: Dahlia, string str: String) -> Dahlia

Print a string as a formatted string, but with a newline after it. Also return the Dahlia object.

pub fn reset(d: Dahlia) -> Dahlia

Print the reset colors character and return the dahlia object.

pub fn with_colors(d: Dahlia, colors: Map(String, Ansi)) -> Dahlia

Use a custom color set for the dahlia object.

import dahlia
import dahlia/colors

fn main() {
  dahlia.new()
  |> dahlia.with_colors(colors.three_bit())
  |> dahlia.print("&aHello Wolrd")
}
pub fn with_escape_character(d: Dahlia, escape_character: String) -> Dahlia

Use a custom escape character for you dahlia strings.

import dahlia
import dahlia/colors

fn main() {
  dahlia.new()
  |> dahlia.with_escape_character("%")
  |> dahlia.print("%aHello Wolrd")
}
Search Document