spruce/box

Boxed terminal output with rounded borders and an optional title.

Types

The border style used by a box.

pub type Border {
  Normal
  Rounded
  Thick
  Double
  Hidden
  Block
  Custom(BorderChars)
}

Constructors

  • Normal
  • Rounded
  • Thick
  • Double
  • Hidden
  • Block
  • Custom(BorderChars)

The characters used to draw a visible border.

pub type BorderChars {
  BorderChars(
    top_left: String,
    top: String,
    top_right: String,
    right: String,
    bottom_right: String,
    bottom: String,
    bottom_left: String,
    left: String,
  )
}

Constructors

  • BorderChars(
      top_left: String,
      top: String,
      top_right: String,
      right: String,
      bottom_right: String,
      bottom: String,
      bottom_left: String,
      left: String,
    )

Box rendering options.

pub opaque type BoxOptions

Values

pub fn border(options: BoxOptions, border: Border) -> BoxOptions

Set the border style.

pub fn border_colors(
  options: BoxOptions,
  top top: style.Color,
  right right: style.Color,
  bottom bottom: style.Color,
  left left: style.Color,
) -> BoxOptions

Set top, right, bottom, and left border colors independently.

pub fn border_sides(
  options: BoxOptions,
  top top: Bool,
  right right: Bool,
  bottom bottom: Bool,
  left left: Bool,
) -> BoxOptions

Set top, right, bottom, and left border visibility independently.

pub fn default_options() -> BoxOptions

Default options: no title, cyan border.

pub fn margin(
  options: BoxOptions,
  top top: Int,
  right right: Int,
  bottom bottom: Int,
  left left: Int,
) -> BoxOptions

Set outer margin as top, right, bottom, left cell counts.

pub fn options(
  title title: String,
  color color: style.Color,
) -> BoxOptions

Build options with an explicit title and border color.

pub fn padding(
  options: BoxOptions,
  top top: Int,
  right right: Int,
  bottom bottom: Int,
  left left: Int,
) -> BoxOptions

Set inner padding as top, right, bottom, left cell counts.

pub fn print(sp: spruce.Spruce, content: String) -> Nil

Render a default box and print it to stdout.

pub fn render(
  sp: spruce.Spruce,
  content: String,
  options: BoxOptions,
) -> String

Render content in a box with the given options.

pub fn simple(sp: spruce.Spruce, content: String) -> String

Render content in a box using the default options.

pub fn width(options: BoxOptions, width: Int) -> BoxOptions

Constrain content to a visual width, wrapping with spruce/align.wrap.

Search Document