Raxol.Terminal.Style.Manager (Raxol v0.5.0)

View Source

Manages text styling and formatting for the terminal emulator. This module provides a clean interface for managing text styles, colors, and attributes.

Summary

Functions

Converts an ANSI color code to a color name.

Applies a text attribute to the style.

Calculates the effective width of a character based on the current style.

Formats SGR parameters for DECRQSS responses.

Gets the background color.

Gets the current style.

Gets the foreground color.

Gets the hyperlink URI.

Creates a new text style with default values.

Resets to single-width, single-height mode.

Resets all text formatting attributes to their default values.

Sets the background color.

Sets double-height bottom half mode for the current line.

Sets double-height top half mode for the current line.

Sets double-width mode for the current line.

Sets the foreground color.

Sets a hyperlink URI.

Sets the style to a new value.

Types

color()

@type color() ::
  :black
  | :red
  | :green
  | :yellow
  | :blue
  | :magenta
  | :cyan
  | :white
  | {:rgb, non_neg_integer(), non_neg_integer(), non_neg_integer()}
  | {:index, non_neg_integer()}
  | nil

text_style()

@type text_style() :: %{
  double_width: boolean(),
  double_height: :none | :top | :bottom,
  bold: boolean(),
  faint: boolean(),
  italic: boolean(),
  underline: boolean(),
  blink: boolean(),
  reverse: boolean(),
  conceal: boolean(),
  strikethrough: boolean(),
  fraktur: boolean(),
  double_underline: boolean(),
  foreground: color(),
  background: color(),
  hyperlink: String.t() | nil
}

Functions

ansi_code_to_color_name(code)

@spec ansi_code_to_color_name(integer()) :: color() | nil

Converts an ANSI color code to a color name.

apply_style(style, attribute)

@spec apply_style(text_style(), atom()) :: text_style()

Applies a text attribute to the style.

effective_width(style, char)

@spec effective_width(text_style(), String.t()) :: integer()

Calculates the effective width of a character based on the current style.

format_sgr_params(style)

@spec format_sgr_params(text_style()) :: String.t()

Formats SGR parameters for DECRQSS responses.

get_background(style)

@spec get_background(text_style()) :: color()

Gets the background color.

get_current_style(style)

@spec get_current_style(text_style()) :: text_style()

Gets the current style.

get_foreground(style)

@spec get_foreground(text_style()) :: color()

Gets the foreground color.

get_hyperlink(style)

@spec get_hyperlink(text_style()) :: String.t() | nil

Gets the hyperlink URI.

new()

@spec new() :: text_style()

Creates a new text style with default values.

reset_size(style)

@spec reset_size(text_style()) :: text_style()

Resets to single-width, single-height mode.

reset_style(style)

@spec reset_style(text_style()) :: text_style()

Resets all text formatting attributes to their default values.

set_background(style, color)

@spec set_background(text_style(), color()) :: text_style()

Sets the background color.

set_double_height_bottom(style)

@spec set_double_height_bottom(text_style()) :: text_style()

Sets double-height bottom half mode for the current line.

set_double_height_top(style)

@spec set_double_height_top(text_style()) :: text_style()

Sets double-height top half mode for the current line.

set_double_width(style)

@spec set_double_width(text_style()) :: text_style()

Sets double-width mode for the current line.

set_foreground(style, color)

@spec set_foreground(text_style(), color()) :: text_style()

Sets the foreground color.

set_hyperlink(style, url)

@spec set_hyperlink(text_style(), String.t() | nil) :: text_style()

Sets a hyperlink URI.

set_style(current_style, new_style)

@spec set_style(text_style(), text_style()) :: text_style()

Sets the style to a new value.