Contains all information related to message printing.
Fields
chunks: List of ChunkText to printalign: Alignment (:left, :center, :right, :justified)padding: Padding (integer or tuple {top, right, bottom, left})add_line: Additional lines (:before, :after, :both, :none)raw_coords: Coordinates for raw mode {x, y}
Examples
iex> MessageInfo.new([ChunkText.new("Hello")])
%MessageInfo{chunks: [...], align: :left, padding: 0, ...}
iex> MessageInfo.new([ChunkText.new("Hello")], align: :center, padding: 2)
%MessageInfo{chunks: [...], align: :center, padding: 2, ...}
Summary
Functions
Gets the complete message text (without formatting).
Gets the message width (text length without formatting).
Creates a new MessageInfo structure.
Normalizes padding to tuple {top, right, bottom, left}.
Types
@type add_line() :: :before | :after | :both | :none
@type align() :: :left | :center | :right | :justified
Functions
Gets the complete message text (without formatting).
Examples
iex> msg = MessageInfo.new(["Hello", " world"])
iex> MessageInfo.get_text(msg)
"Hello world"
Gets the message width (text length without formatting).
Examples
iex> msg = MessageInfo.new(["Hello world"])
iex> MessageInfo.get_width(msg)
11
@spec new( [String.t() | Alaja.Structures.ChunkText.t()], keyword() ) :: t()
Creates a new MessageInfo structure.
Parameters
chunks- List of ChunkText or strings (automatically converted)opts- Options::align- Alignment (default: :left):padding- Padding (default: 0):add_line- Additional lines (default: :none):raw_coords- Coordinates for raw mode (default: nil)
Examples
iex> MessageInfo.new(["Hello", " world"])
%MessageInfo{chunks: [...], align: :left}
iex> MessageInfo.new([ChunkText.new("Hello")], align: :center, padding: 2)
%MessageInfo{chunks: [...], align: :center, padding: 2}
Normalizes padding to tuple {top, right, bottom, left}.
Examples
iex> MessageInfo.normalize_padding(2)
{2, 2, 2, 2}
iex> MessageInfo.normalize_padding({1, 2, 3, 4})
{1, 2, 3, 4}