# `Alaja.Printer`
[🔗](https://github.com/Lorenzo-SF/alaja/blob/2.1.0/lib/alaja/printer.ex#L1)

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)

# `print`

```elixir
@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_msg` — `MessageInfo` 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"

# `print_alert`

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

# `print_buffer`

```elixir
@spec print_buffer(
  Alaja.Buffer.t(),
  keyword()
) :: :ok | String.t()
```

Prints a `Alaja.Buffer.t()` to the terminal, optionally positioned at
`(x, y)` via ANSI cursor escape. Unlike `print_raw/2`, this preserves
the 2D structure of the buffer when positioning it on screen.

## Options

- `:x` / `:pos_x` / `:"pos-x"` — column (default 0)
- `:y` / `:pos_y` / `:"pos-y"` — row (default 0)
- `:verbose` — return the rendered string instead of writing
- `:clear_line` — when `true`, prepend `[K` to each row to clear
  trailing characters (default `true`)

## Examples

    buffer = Alaja.Buffer.new(5, 1) |> Alaja.Buffer.put(0, 0, "X", {255, 0, 0})
    Alaja.Printer.print_buffer(buffer, x: 10, y: 5)

# `print_critical`

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

# `print_debug`

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

# `print_emergency`

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

# `print_error`

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

# `print_info`

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

# `print_message`

```elixir
@spec print_message(atom(), String.t()) :: :ok
```

Prints a message with a given severity level.

Dispatches dynamically to the corresponding `Basics.print_*/2`
function. Unknown levels fall back to plain white text.

# `print_notice`

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

# `print_raw`

```elixir
@spec print_raw(iodata() | Alaja.Buffer.t()) :: :ok | String.t()
```

Prints raw iodata or a string directly to the terminal.

This is a convenience function equivalent to `print_raw(data, [])`.

## Parameters

- `data` — iodata or string to print

## Examples

    iex> Alaja.Printer.print_raw("Hello")
    :ok

# `print_raw`

```elixir
@spec print_raw(
  iodata() | Alaja.Buffer.t(),
  keyword()
) :: :ok | String.t()
```

Prints raw iodata, a string, or an `Alaja.Buffer.t()` with global
formatting options.

Accepts the same options as `print/2` (`:raw`, `:x`, `:y`,
`:verbose`). Also supports box wrapping via `:box`, `:box_title`,
`:box_border`, `:box_color`, and alignment via `:align`.

If `data` is an `Alaja.Buffer.t()`, it is rendered via
`Buffer.to_iodata/1` first. Box wrapping requires a string/iodata;
pass a Buffer to `Box.render/2` directly if you need a Buffer-in,
Buffer-out pipeline.

# `print_success`

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

# `print_warning`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
