Alaja.Printer (Alaja v1.0.0)

Copy Markdown View Source

Central I/O dispatcher for terminal rendering.

Delegates message-level printing to Alaja.Printer.Basics and provides the main print/2 function for rendering MessageInfo structs, plain strings, or raw iodata with optional ANSI cursor positioning.

Usage

Alaja.Printer.print(MessageInfo.new(["Hello"]))
Alaja.Printer.print_success("Operation completed!")
Alaja.Printer.print_error("Something went wrong")
Alaja.Printer.print("Loading...", raw: true, x: 10, y: 5)

Summary

Functions

Prints a MessageInfo, string, list, or iodata to the terminal.

Prints an alert message (icon: 🔔). Delegates to Basics.print_alert/2.

Prints a critical message (icon: 🔥). Delegates to Basics.print_critical/2.

Prints a debug message (icon: ⚙). Delegates to Basics.print_debug/2.

Prints an emergency message (icon: 🆘). Delegates to Basics.print_emergency/2.

Prints an error message (icon: ✗). Delegates to Basics.print_error/2.

Prints an info message (icon: ℹ). Delegates to Basics.print_info/2.

Prints a message with a given severity level.

Prints a notice message (icon: 📢). Delegates to Basics.print_notice/2.

Prints raw iodata or a string directly to the terminal.

Prints raw iodata or a string with global formatting options.

Prints a success message (icon: ✓). Delegates to Basics.print_success/2.

Prints a warning message (icon: ⚠). Delegates to Basics.print_warning/2.

Functions

print(text_or_msg, opts \\ [])

@spec print(
  Alaja.Structures.MessageInfo.t() | String.t() | list() | iodata(),
  keyword()
) :: :ok | String.t()

Prints a MessageInfo, string, list, or iodata to the terminal.

Parameters

  • text_or_msgMessageInfo struct, plain string, chunk list, or iodata.

Options

  • :raw — if true, print at the given :x/:y coordinates using ANSI cursor positioning.
  • :x — X coordinate for raw mode (0-indexed).
  • :y — Y coordinate for raw mode (0-indexed).
  • :"pos-x", :"pos-y" — alternative key names for coordinates.
  • :verbose — if true, write to stdout and return the rendered string instead of :ok.

Examples

iex> msg = MessageInfo.new([ChunkText.new("Hello", color: :blue)])
iex> Alaja.Printer.print(msg)
:ok

iex> Alaja.Printer.print("Hello", raw: true, x: 10, y: 5)
:ok

iex> Alaja.Printer.print("Hello", verbose: true)
"\e[38;2;0;180;216mHello\e[0m"