Raxol.Terminal.Config (Raxol v0.5.0)

View Source

Handles terminal settings and behavior, including:

  • Terminal dimensions
  • Color settings
  • Input handling
  • Terminal state management
  • Configuration validation
  • Configuration persistence

Summary

Functions

Gets the current color settings.

Gets the current terminal dimensions.

Gets the current input handling settings.

Gets the current terminal mode settings.

Gets the current performance settings.

Gets the current style settings.

Lists all saved configurations.

Loads a configuration from persistent storage.

Merges a map of options with the current configuration. Validates the options before merging.

Creates a new terminal configuration with default values.

Creates a new terminal configuration with custom dimensions.

Saves the configuration to persistent storage.

Updates the color settings.

Updates the terminal dimensions.

Updates the input handling settings.

Updates the terminal mode settings.

Updates the performance settings.

Updates the style settings.

Updates the terminal configuration with validation.

Validates a configuration map. Checks for required fields and valid values.

Types

t()

@type t() :: %Raxol.Terminal.Config{
  colors: map(),
  height: non_neg_integer(),
  input: map(),
  mode: map(),
  performance: map(),
  styles: map(),
  version: non_neg_integer(),
  width: non_neg_integer()
}

Functions

get_colors(config)

@spec get_colors(t()) :: map()

Gets the current color settings.

Parameters

  • config - The current configuration

Returns

A map containing the current color settings.

get_dimensions(config)

@spec get_dimensions(t()) :: {integer(), integer()}

Gets the current terminal dimensions.

Parameters

  • config - The current configuration

Returns

A tuple {width, height} with the current dimensions.

get_input(config)

@spec get_input(t()) :: map()

Gets the current input handling settings.

Parameters

  • config - The current configuration

Returns

A map containing the current input settings.

get_mode(config)

@spec get_mode(t()) :: map()

Gets the current terminal mode settings.

Parameters

  • config - The current configuration

Returns

A map containing the current mode settings.

get_performance(config)

@spec get_performance(t()) :: map()

Gets the current performance settings.

Parameters

  • config - The current configuration

Returns

A map containing the current performance settings.

get_styles(config)

@spec get_styles(t()) :: map()

Gets the current style settings.

Parameters

  • config - The current configuration

Returns

A map containing the current style settings.

list_saved()

@spec list_saved() :: {:ok, [String.t()]} | {:error, term()}

Lists all saved configurations.

load(name)

@spec load(String.t()) :: {:ok, t()} | {:error, term()}

Loads a configuration from persistent storage.

merge_opts(config, opts)

Merges a map of options with the current configuration. Validates the options before merging.

Parameters

  • config - The current configuration
  • opts - A map of options to merge

Returns

The updated configuration with merged options.

new()

@spec new() :: t()

Creates a new terminal configuration with default values.

Returns

A new Raxol.Terminal.Config.t/0 struct with default values.

new(width, height)

@spec new(integer(), integer()) :: t()

Creates a new terminal configuration with custom dimensions.

Parameters

  • width - The terminal width in characters
  • height - The terminal height in characters

Returns

A new Raxol.Terminal.Config.t/0 struct with the specified dimensions.

save(config, name)

@spec save(t(), String.t()) :: :ok | {:error, term()}

Saves the configuration to persistent storage.

set_colors(config, colors)

@spec set_colors(t(), map()) :: t()

Updates the color settings.

Parameters

  • config - The current configuration
  • colors - A map of color settings to update

Returns

The updated configuration with new color settings.

set_dimensions(config, width, height)

@spec set_dimensions(t(), integer(), integer()) :: t()

Updates the terminal dimensions.

Parameters

  • config - The current configuration
  • width - The new terminal width
  • height - The new terminal height

Returns

The updated configuration with new dimensions.

set_input(config, input)

@spec set_input(t(), map()) :: t()

Updates the input handling settings.

Parameters

  • config - The current configuration
  • input - A map of input settings to update

Returns

The updated configuration with new input settings.

set_mode(config, mode)

@spec set_mode(t(), map()) :: t()

Updates the terminal mode settings.

Parameters

  • config - The current configuration
  • mode - A map of mode settings to update

Returns

The updated configuration with new mode settings.

set_performance(config, performance)

@spec set_performance(t(), map()) :: t()

Updates the performance settings.

Parameters

  • config - The current configuration
  • performance - A map of performance settings to update

Returns

The updated configuration with new performance settings.

set_styles(config, styles)

@spec set_styles(t(), map()) :: t()

Updates the style settings.

Parameters

  • config - The current configuration
  • styles - A map of style settings to update

Returns

The updated configuration with new style settings.

update(config, updates)

@spec update(t(), map()) :: {:ok, t()} | {:error, term()}

Updates the terminal configuration with validation.

validate_config(config)

Validates a configuration map. Checks for required fields and valid values.

Parameters

  • config - The configuration to validate

Returns

:ok if the configuration is valid, {:error, reason} otherwise.