Minimal text chunk with formatting.
Represents a text fragment with its color and effects information. This is the basic composition unit for formatted text rendering.
Examples
iex> ChunkText.new("Hello world")
%ChunkText{text: "Hello world", color: nil, bg_color: nil, effects: nil}
iex> ChunkText.new("Hello", color: :red, effects: [:bold])
%ChunkText{text: "Hello", color: %ColorInfo{...}, effects: %EffectInfo{...}}
Summary
Functions
Combines two ChunkTexts (useful for concatenating formatted text).
Creates a new ChunkText.
Renders the ChunkText with ANSI codes.
Types
@type t() :: %Alaja.Structures.ChunkText{ bg_color: Pote.ColorInfo.t() | nil, color: Pote.ColorInfo.t() | nil, effects: Alaja.Structures.EffectInfo.t() | nil, text: String.t() }
Functions
Combines two ChunkTexts (useful for concatenating formatted text).
The second chunk's properties take precedence over the first's.
Examples
iex> c1 = ChunkText.new("Hello", color: :red)
iex> c2 = ChunkText.new(" world", color: :green)
iex> ChunkText.combine(c1, c2)
%ChunkText{text: "Hello world", color: %ColorInfo{...}}
Creates a new ChunkText.
Parameters
text- The text to displayopts- Optional options::color- ColorInfo or convertible value (atom, hex, rgb, etc.):bg_color- Background ColorInfo or convertible value:effects- EffectInfo or list of effects
Examples
iex> ChunkText.new("Hello")
%ChunkText{text: "Hello"}
iex> ChunkText.new("Hello", color: :red)
%ChunkText{text: "Hello", color: %ColorInfo{...}}
iex> ChunkText.new("Hello", color: "#FF0000", effects: [:bold, :underline])
%ChunkText{text: "Hello", color: %ColorInfo{...}, effects: %EffectInfo{...}}
Renders the ChunkText with ANSI codes.
Produces true-color (24-bit) ANSI sequences with effects. Always resets formatting after the text.
Examples
iex> ChunkText.render(ChunkText.new("Hello", color: :red, effects: [:bold]))
"\e[38;2;255;0;0m\e[1mHello\e[0m"