wink

A simple Gleam box drawing library

Types

Represents the borders of a box.

pub type Border {
  Border(
    top_right: String,
    top_left: String,
    bottom_right: String,
    bottom_left: String,
    horizontal: String,
    vertical: String,
  )
}

Constructors

  • Border(
      top_right: String,
      top_left: String,
      bottom_right: String,
      bottom_left: String,
      horizontal: String,
      vertical: String,
    )

Represents a box instance.

pub type Box {
  Box(draw: fn(String) -> String)
}

Constructors

  • Box(draw: fn(String) -> String)

Represents different colors for drawing boxes.

pub type Color {
  Black
  Red
  Green
  Yellow
  Blue
  Magenta
  Cyan
  White
  Default
  ResetColor
}

Constructors

  • Black
  • Red
  • Green
  • Yellow
  • Blue
  • Magenta
  • Cyan
  • White
  • Default
  • ResetColor

Represents the configuration for drawing a box.

pub type Config {
  Config(
    style: Style,
    box_color: Color,
    text_color: Color,
    padding: Spacing,
    margin: Spacing,
    decorations: List(Decoration),
  )
}

Constructors

  • Config(
      style: Style,
      box_color: Color,
      text_color: Color,
      padding: Spacing,
      margin: Spacing,
      decorations: List(Decoration),
    )

Represents different decorations for text.

pub type Decoration {
  Bold
  Dim
  Italic
  Underline
  Reversed
  ResetDecoration
}

Constructors

  • Bold
  • Dim
  • Italic
  • Underline
  • Reversed
  • ResetDecoration

Represents spacing around the content of a box.

pub type Spacing {
  Spacing(top: Int, right: Int, bottom: Int, left: Int)
}

Constructors

  • Spacing(top: Int, right: Int, bottom: Int, left: Int)

Represents different styles for drawing boxes.

pub type Style {
  Single
  Round
  Solid
  Frame
  Cross
  Spring
  Thick
  Double
  SingleDouble
  DoubleSingle
  Classic
  Hidden
  Custom(Border)
}

Constructors

  • Single
  • Round
  • Solid
  • Frame
  • Cross
  • Spring
  • Thick
  • Double
  • SingleDouble
  • DoubleSingle
  • Classic
  • Hidden
  • Custom(Border)

Constants

pub const default_config: Config = Config(
  style: Round,
  box_color: Default,
  text_color: Default,
  padding: Spacing(top: 1, right: 1, bottom: 1, left: 1),
  margin: Spacing(top: 1, right: 1, bottom: 1, left: 1),
  decorations: [],
)

Default configuration for drawing a box.

Functions

pub fn draw(msg: String) -> String

Draws a box with the default configuration.

pub fn init(cfg: Config) -> Box

Initializes a box with the given configuration.

Search Document