Boxart.Utils (Boxart v0.3.2)

Copy Markdown View Source

Shared utility functions for terminal rendering.

Summary

Functions

Returns the terminal display width of text.

Left-justify str to width using spaces.

Right-justify str to width using spaces.

Functions

display_width(text)

@spec display_width(String.t()) :: non_neg_integer()

Returns the terminal display width of text.

East-Asian wide/fullwidth characters and emoji occupy 2 terminal columns; everything else occupies 1.

ljust(str, width)

@spec ljust(String.t(), non_neg_integer()) :: String.t()

Left-justify str to width using spaces.

rjust(str, width)

@spec rjust(String.t(), non_neg_integer()) :: String.t()

Right-justify str to width using spaces.