Raxol.Terminal.Style.Manager (Raxol Terminal v2.6.0)

Copy Markdown 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() :: %{
  background: color(),
  blink: boolean(),
  bold: boolean(),
  conceal: boolean(),
  double_height: :bottom | :none | :top,
  double_underline: boolean(),
  double_width: boolean(),
  encircled: boolean(),
  faint: boolean(),
  foreground: color(),
  fraktur: boolean(),
  framed: boolean(),
  hyperlink: nil | binary(),
  italic: boolean(),
  overlined: boolean(),
  reverse: boolean(),
  strikethrough: boolean(),
  underline: boolean()
}

Functions

ansi_code_to_color_name(code)

@spec ansi_code_to_color_name(integer()) ::
  :black
  | :red
  | :green
  | :yellow
  | :blue
  | :magenta
  | :cyan
  | :white
  | :bright_black
  | :bright_red
  | :bright_green
  | :bright_yellow
  | :bright_blue
  | :bright_magenta
  | :bright_cyan
  | :bright_white
  | nil

Converts an ANSI color code to a color name.

apply_style(style, attribute)

Applies a text attribute to the style.

effective_width(style, char)

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

format_sgr_params(style)

@spec format_sgr_params(Raxol.Terminal.ANSI.TextFormatting.t()) :: String.t()

Formats SGR parameters for DECRQSS responses.

get_background(style)

@spec get_background(Raxol.Terminal.ANSI.TextFormatting.t()) :: color()

Gets the background color.

get_current_style(style)

Gets the current style.

get_foreground(style)

@spec get_foreground(Raxol.Terminal.ANSI.TextFormatting.t()) :: color()

Gets the foreground color.

get_hyperlink(style)

@spec get_hyperlink(Raxol.Terminal.ANSI.TextFormatting.t()) :: String.t() | nil

Gets the hyperlink URI.

new()

Creates a new text style with default values.

reset_size(style)

Resets to single-width, single-height mode.

reset_style(style)

Resets all text formatting attributes to their default values.

set_background(style, color)

Sets the background color.

set_double_height_bottom(style)

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

set_double_height_top(style)

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

set_double_width(style)

Sets double-width mode for the current line.

set_foreground(style, color)

Sets the foreground color.

set_hyperlink(style, url)

Sets a hyperlink URI.

set_style(current_style, new_style)

Sets the style to a new value.