Raxol.Terminal.Commands.CommandServer (Raxol v2.0.1)

View Source

Unified command handler that consolidates all terminal command processing.

This module replaces the fragmented handler pattern with a single, organized command processing system that handles:

  • Cursor movement and positioning commands
  • Device status and attribute commands
  • Erase operations (screen, line, character)
  • CSI (Control Sequence Introducer) commands
  • OSC (Operating System Command) sequences
  • DCS (Device Control String) commands
  • Mode setting and resetting
  • Text formatting and styling
  • Window operations
  • Buffer operations

Design Principles

  1. Unified Interface: Single entry point for all command processing
  2. Command Routing: Intelligent routing based on command type and parameters
  3. State Management: Consistent state handling across all command types
  4. Error Handling: Centralized error handling with graceful fallbacks
  5. Performance: Optimized dispatching with minimal overhead
  6. Extensibility: Easy to add new command types and handlers

Command Categories

  • Cursor Commands: CUP, CUU, CUD, CUF, CUB, HVP, etc.
  • Erase Commands: ED, EL, ECH, etc.
  • Device Commands: DA, DSR, CPR, etc.
  • Mode Commands: SM, RM, DECSET, DECRST, etc.
  • Text Commands: SGR, TBC, CTC, etc.
  • Window Commands: Window resize, title setting, etc.
  • Buffer Commands: Buffer switching, scrolling, etc.

Summary

Functions

Processes any terminal command with unified handling.

Handles CSI (Control Sequence Introducer) commands.

Handles OSC (Operating System Command) sequences.

Types

command_params()

@type command_params() :: %{
  type: command_type(),
  command: String.t(),
  params: [integer()],
  intermediates: String.t(),
  private_markers: String.t()
}

command_result()

@type command_result() ::
  {:ok, Raxol.Terminal.Emulator.t()}
  | {:error, atom(), Raxol.Terminal.Emulator.t()}

command_type()

@type command_type() :: :csi | :osc | :dcs | :escape | :control

Functions

handle_command(emulator, cmd_params)

@spec handle_command(Raxol.Terminal.Emulator.t(), command_params()) ::
  command_result()

Processes any terminal command with unified handling.

This is the main entry point for all command processing.

handle_csi(emulator, command, params \\ [], intermediates \\ "")

@spec handle_csi(Raxol.Terminal.Emulator.t(), String.t(), [integer()], String.t()) ::
  command_result()

Handles CSI (Control Sequence Introducer) commands.

handle_osc(emulator, command, data)

Handles OSC (Operating System Command) sequences.