Raxol.Terminal.OutputManager (Raxol v0.5.0)

View Source

Manages terminal output buffering, control sequences, and formatting. Provides functionality for:

  • Output buffering with size limits
  • Control sequence handling
  • Output formatting and styling
  • Performance metrics tracking
  • Batch processing

Summary

Functions

Adds a custom formatting rule to the manager.

Clears the control sequence buffer.

Clears the output buffer.

Enqueues a control sequence to the buffer. Returns {:ok, updated_manager} or {:error, :buffer_overflow}

Enqueues output to the buffer. Returns {:ok, updated_manager} or {:error, :buffer_overflow}

Flushes the control sequence buffer and returns its contents. Returns {sequences, updated_manager}

Flushes the output buffer and returns its contents. Returns {output, updated_manager}

Gets the current control sequence buffer contents.

Gets the current metrics.

Gets the current output buffer contents.

Creates a new OutputManager with default settings.

Types

t()

@type t() :: %Raxol.Terminal.OutputManager{
  batch_size: integer(),
  control_sequence_buffer: String.t(),
  format_rules: [function()],
  max_buffer_size: integer(),
  metrics: %{
    processed_bytes: integer(),
    control_sequences: integer(),
    format_applications: integer(),
    style_applications: integer(),
    buffer_overflows: integer()
  },
  output_buffer: String.t(),
  style_map: %{required(String.t()) => map()}
}

Functions

add_format_rule(manager, rule)

@spec add_format_rule(t(), function()) :: t()

Adds a custom formatting rule to the manager.

clear_control_sequence_buffer(manager)

@spec clear_control_sequence_buffer(t()) :: t()

Clears the control sequence buffer.

clear_output_buffer(manager)

@spec clear_output_buffer(t()) :: t()

Clears the output buffer.

enqueue_control_sequence(manager, sequence)

@spec enqueue_control_sequence(t(), String.t()) ::
  {:ok, t()} | {:error, :buffer_overflow}

Enqueues a control sequence to the buffer. Returns {:ok, updated_manager} or {:error, :buffer_overflow}

enqueue_output(manager, output)

@spec enqueue_output(t(), String.t()) :: {:ok, t()} | {:error, :buffer_overflow}

Enqueues output to the buffer. Returns {:ok, updated_manager} or {:error, :buffer_overflow}

flush_control_sequence_buffer(manager)

@spec flush_control_sequence_buffer(t()) :: {String.t(), t()}

Flushes the control sequence buffer and returns its contents. Returns {sequences, updated_manager}

flush_output(manager)

@spec flush_output(t()) :: {String.t(), t()}

Flushes the output buffer and returns its contents. Returns {output, updated_manager}

get_control_sequence_buffer(manager)

@spec get_control_sequence_buffer(t()) :: String.t()

Gets the current control sequence buffer contents.

get_metrics(manager)

@spec get_metrics(t()) :: map()

Gets the current metrics.

get_output_buffer(manager)

@spec get_output_buffer(t()) :: String.t()

Gets the current output buffer contents.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new OutputManager with default settings.