Inline styling DSL — compose foreground, background and text effects
into an immutable %Pote.Style{} struct, then render text with ANSI
escapes.
Pote.Style is the agnostic, terminal-agnostic layer: it resolves
colors (atoms from Pote.Colors.Basic, RGB tuples, hex strings via
Pote.parse/1) and emits truecolor ANSI. Deciding whether to fall
back to 256-color or no-color modes is the host's job (alaja does this
for the TUI).
Example
iex> style = Pote.Style.red() |> Pote.Style.bold() |> Pote.Style.on("#1e1e2e")
iex> style.fg
{255, 0, 0}
iex> style.bg
{30, 30, 46}
iex> style.effects
[:bold]
iex> Pote.Style.render(style, "hi") |> IO.iodata_to_binary()
"[1m[38;2;255;0;0m[48;2;30;30;46mhi[0m"
Summary
Functions
Returns a style with aqua as the foreground color.
Sets the background color on a style. Alias of on/2.
Returns a style with black as the foreground color.
Adds the blink effect to the style.
Returns a style with blue as the foreground color.
Adds the bold effect to the style.
Returns a style with bright_black as the foreground color.
Returns a style with bright_blue as the foreground color.
Returns a style with bright_cyan as the foreground color.
Returns a style with bright_green as the foreground color.
Returns a style with bright_magenta as the foreground color.
Returns a style with bright_red as the foreground color.
Returns a style with bright_white as the foreground color.
Returns a style with bright_yellow as the foreground color.
Returns a style with cyan as the foreground color.
Adds the dim effect to the style.
Sets the foreground color on a style.
Returns a style with fuchsia as the foreground color.
Returns a style with gray as the foreground color.
Returns a style with green as the foreground color.
Returns a style with grey as the foreground color.
Adds the hidden effect to the style.
Returns a style with indigo as the foreground color.
Adds the inverse effect to the style.
Adds the italic effect to the style.
Returns a style with lime as the foreground color.
Returns a style with magenta as the foreground color.
Returns a style with maroon as the foreground color.
Returns a style with navy as the foreground color.
Returns an empty style (no fg, no bg, no effects).
Returns a style with olive as the foreground color.
Sets the background color on a style (terminal-idiomatic "on").
Returns a style with orange as the foreground color.
Returns a style with pink as the foreground color.
Returns a style with purple as the foreground color.
Returns a style with red as the foreground color.
Renders text with the style applied, including the reset sequence.
Returns a style with silver as the foreground color.
Returns a style with teal as the foreground color.
Returns the ANSI escape sequence for the style as iodata.
Adds the underline effect to the style.
Returns a style with violet as the foreground color.
Returns a style with white as the foreground color.
Returns a style with yellow as the foreground color.
Types
Functions
Returns a style with aqua as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
@spec bg(t(), color_input()) :: t()
Sets the background color on a style. Alias of on/2.
Examples
iex> Pote.Style.new() |> Pote.Style.bg("#1e1e2e")
%Pote.Style{fg: nil, bg: {30, 30, 46}, effects: []}
Returns a style with black as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Adds the blink effect to the style.
Examples
iex> Pote.Style.bold().effects
[:bold]
Returns a style with blue as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Adds the bold effect to the style.
Examples
iex> Pote.Style.bold().effects
[:bold]
Returns a style with bright_black as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with bright_blue as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with bright_cyan as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with bright_green as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with bright_magenta as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with bright_red as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with bright_white as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with bright_yellow as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with cyan as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Adds the dim effect to the style.
Examples
iex> Pote.Style.bold().effects
[:bold]
@spec fg(t(), color_input()) :: t()
Sets the foreground color on a style.
Accepts a color name atom (:red), an RGB tuple, or a hex string
("#ff0000").
Examples
iex> Pote.Style.new() |> Pote.Style.fg(:red)
%Pote.Style{fg: {255, 0, 0}, bg: nil, effects: []}
Returns a style with fuchsia as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with gray as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with green as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with grey as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with indigo as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Adds the inverse effect to the style.
Examples
iex> Pote.Style.bold().effects
[:bold]
Adds the italic effect to the style.
Examples
iex> Pote.Style.bold().effects
[:bold]
Returns a style with lime as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with magenta as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with maroon as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
@spec new() :: t()
Returns an empty style (no fg, no bg, no effects).
Examples
iex> Pote.Style.new()
%Pote.Style{fg: nil, bg: nil, effects: []}
Returns a style with olive as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
@spec on(t(), color_input()) :: t()
Sets the background color on a style (terminal-idiomatic "on").
Examples
iex> Pote.Style.red() |> Pote.Style.on(:black)
%Pote.Style{fg: {255, 0, 0}, bg: {0, 0, 0}, effects: []}
Returns a style with orange as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with pink as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with purple as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with red as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Renders text with the style applied, including the reset sequence.
Examples
iex> Pote.Style.red() |> Pote.Style.render("hi") |> IO.iodata_to_binary()
"[38;2;255;0;0mhi[0m"
Returns a style with silver as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with teal as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns the ANSI escape sequence for the style as iodata.
The result is a binary suitable to be prepended to text; it does not
include the reset sequence (use render/2 for that).
Examples
iex> Pote.Style.red() |> Pote.Style.to_ansi()
"[38;2;255;0;0m"
Adds the underline effect to the style.
Examples
iex> Pote.Style.bold().effects
[:bold]
Returns a style with violet as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with white as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}
Returns a style with yellow as the foreground color.
Examples
iex> Pote.Style.red().fg
{255, 0, 0}