Raxol.Terminal.EmulatorLite (Raxol v2.0.1)

View Source

Lightweight terminal emulator for performance-critical paths.

This is a pure struct-based emulator without GenServer processes, designed for fast parsing and simple terminal operations.

For full-featured terminal emulation with state management and concurrent operations, use Raxol.Terminal.Emulator.

Summary

Functions

Gets the active screen buffer.

Moves the cursor to a specific position.

Updates the cursor position relatively.

Creates a new lightweight emulator with minimal overhead.

Creates a minimal emulator for fastest possible parsing. No history, no alternate buffer, minimal features.

Resets the emulator to initial state.

Resizes the emulator to new dimensions.

Switches between main and alternate screen buffers.

Updates the active screen buffer.

Types

t()

@type t() :: %Raxol.Terminal.EmulatorLite{
  active_buffer_type: :main | :alternate,
  alternate_screen_buffer: Raxol.Terminal.ScreenBuffer.t() | nil,
  charset_state: map(),
  client_options: map(),
  command_history: list() | nil,
  current_command_buffer: String.t() | nil,
  cursor: Raxol.Terminal.Cursor.t(),
  cursor_style: atom(),
  height: non_neg_integer(),
  last_col_exceeded: boolean(),
  main_screen_buffer: Raxol.Terminal.ScreenBuffer.t(),
  max_command_history: non_neg_integer(),
  mode_manager: Raxol.Terminal.ModeManager.t(),
  mode_state: map(),
  output_buffer: String.t(),
  parser_state: any(),
  saved_cursor: Raxol.Terminal.Cursor.t() | nil,
  saved_style: Raxol.Terminal.ANSI.TextFormatting.t() | nil,
  scroll_region: {non_neg_integer(), non_neg_integer()} | nil,
  scrollback_buffer: list(),
  scrollback_limit: non_neg_integer(),
  session_id: String.t() | nil,
  style: Raxol.Terminal.ANSI.TextFormatting.t(),
  width: non_neg_integer(),
  window_state: map(),
  window_title: String.t() | nil
}

Functions

get_active_buffer(emulator_lite)

@spec get_active_buffer(t()) :: Raxol.Terminal.ScreenBuffer.t()

Gets the active screen buffer.

move_cursor(emulator, x, y)

@spec move_cursor(t(), non_neg_integer(), non_neg_integer()) :: t()

Moves the cursor to a specific position.

move_cursor_relative(emulator, dx, dy)

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

Updates the cursor position relatively.

new(width \\ 80, height \\ 24, opts \\ [])

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

Creates a new lightweight emulator with minimal overhead.

Options:

  • :enable_history - Enable command history tracking (default: false)
  • :scrollback_limit - Number of scrollback lines (default: 1000)
  • :alternate_buffer - Create alternate screen buffer (default: false)

new_minimal(width \\ 80, height \\ 24)

@spec new_minimal(non_neg_integer(), non_neg_integer()) :: t()

Creates a minimal emulator for fastest possible parsing. No history, no alternate buffer, minimal features.

reset(emulator)

@spec reset(t()) :: t()

Resets the emulator to initial state.

resize(emulator, new_width, new_height)

@spec resize(t(), non_neg_integer(), non_neg_integer()) :: t()

Resizes the emulator to new dimensions.

switch_buffer(emulator, atom)

@spec switch_buffer(t(), :main | :alternate) :: t()

Switches between main and alternate screen buffers.

update_active_buffer(emulator, fun)

@spec update_active_buffer(t(), (Raxol.Terminal.ScreenBuffer.t() ->
                             Raxol.Terminal.ScreenBuffer.t())) ::
  t()

Updates the active screen buffer.