Raxol.Terminal.ANSI.Sequences.Colors (Raxol v0.4.0)

View Source

ANSI Color Sequence Handler.

Handles parsing and application of ANSI color control sequences, including 16-color mode, 256-color mode, and true color (24-bit) mode.

Summary

Functions

Generate ANSI color code for a given color.

Returns a map of ANSI color codes.

Set background color using 256-color mode.

Set background color using basic 16-color mode.

Set background color using true (24-bit) RGB color.

Set foreground color using 256-color mode.

Set foreground color using basic 16-color mode.

Set foreground color using true (24-bit) RGB color.

Functions

color_code(color, arg2)

Generate ANSI color code for a given color.

Parameters

  • color - The color struct
  • type - Either :foreground or :background

Returns

ANSI escape sequence as string

color_codes()

Returns a map of ANSI color codes.

Returns

A map of color names to ANSI codes.

Examples

iex> Raxol.Terminal.ANSI.Sequences.Colors.color_codes()
%{
  black: "",
  red: "",
  # ... other colors ...
  reset: ""
}

set_background_256(emulator, index)

Set background color using 256-color mode.

Parameters

  • emulator - The terminal emulator state
  • index - Color index (0-255)

Returns

Updated emulator state

set_background_basic(emulator, color_code)

Set background color using basic 16-color mode.

Parameters

  • emulator - The terminal emulator state
  • color_code - Color code (0-15)

Returns

Updated emulator state

set_background_true(emulator, r, g, b)

Set background color using true (24-bit) RGB color.

Parameters

  • emulator - The terminal emulator state
  • r - Red component (0-255)
  • g - Green component (0-255)
  • b - Blue component (0-255)

Returns

Updated emulator state

set_foreground_256(emulator, index)

Set foreground color using 256-color mode.

Parameters

  • emulator - The terminal emulator state
  • index - Color index (0-255)

Returns

Updated emulator state

set_foreground_basic(emulator, color_code)

Set foreground color using basic 16-color mode.

Parameters

  • emulator - The terminal emulator state
  • color_code - Color code (0-15)

Returns

Updated emulator state

set_foreground_true(emulator, r, g, b)

Set foreground color using true (24-bit) RGB color.

Parameters

  • emulator - The terminal emulator state
  • r - Red component (0-255)
  • g - Green component (0-255)
  • b - Blue component (0-255)

Returns

Updated emulator state