Raxol.Terminal.ANSI.Sequences.Colors (Raxol v0.5.0)
View SourceANSI 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.
Parse a color string into a Color struct.
Set the background color.
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 a color at a specific index in the color palette.
Set the cursor color.
Set the foreground 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.
Set the highlight background color.
Set the highlight cursor color.
Set the highlight foreground color.
Set the highlight mouse background color.
Set the highlight mouse foreground color.
Set the mouse background color.
Set the mouse foreground color.
Functions
Generate ANSI color code for a given color.
Parameters
color
- The color structtype
- Either :foreground or :background
Returns
ANSI escape sequence as string
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: "[30m",
red: "[31m",
# ... other colors ...
reset: "[0m"
}
Parse a color string into a Color struct.
Parameters
color_str
- Color string in format "rgb:RRRR/GGGG/BBBB" or "#RRGGBB"
Returns
Color struct or nil if invalid format
Set the background color.
Parameters
colors
- The color palettecolor
- Color struct
Returns
Updated color palette
Set background color using 256-color mode.
Parameters
emulator
- The terminal emulator stateindex
- Color index (0-255)
Returns
Updated emulator state
Set background color using basic 16-color mode.
Parameters
emulator
- The terminal emulator statecolor_code
- Color code (0-15)
Returns
Updated emulator state
Set background color using true (24-bit) RGB color.
Parameters
emulator
- The terminal emulator stater
- Red component (0-255)g
- Green component (0-255)b
- Blue component (0-255)
Returns
Updated emulator state
Set a color at a specific index in the color palette.
Parameters
colors
- The color paletteindex
- Color index (0-255)color
- Color struct
Returns
Updated color palette
Set the cursor color.
Parameters
colors
- The color palettecolor
- Color struct
Returns
Updated color palette
Set the foreground color.
Parameters
colors
- The color palettecolor
- Color struct
Returns
Updated color palette
Set foreground color using 256-color mode.
Parameters
emulator
- The terminal emulator stateindex
- Color index (0-255)
Returns
Updated emulator state
Set foreground color using basic 16-color mode.
Parameters
emulator
- The terminal emulator statecolor_code
- Color code (0-15)
Returns
Updated emulator state
Set foreground color using true (24-bit) RGB color.
Parameters
emulator
- The terminal emulator stater
- Red component (0-255)g
- Green component (0-255)b
- Blue component (0-255)
Returns
Updated emulator state
Set the highlight background color.
Parameters
colors
- The color palettecolor
- Color struct
Returns
Updated color palette
Set the highlight cursor color.
Parameters
colors
- The color palettecolor
- Color struct
Returns
Updated color palette
Set the highlight foreground color.
Parameters
colors
- The color palettecolor
- Color struct
Returns
Updated color palette
Set the highlight mouse background color.
Parameters
colors
- The color palettecolor
- Color struct
Returns
Updated color palette
Set the highlight mouse foreground color.
Parameters
colors
- The color palettecolor
- Color struct
Returns
Updated color palette
Set the mouse background color.
Parameters
colors
- The color palettecolor
- Color struct
Returns
Updated color palette
Set the mouse foreground color.
Parameters
colors
- The color palettecolor
- Color struct
Returns
Updated color palette