Raxol.Terminal.Commands (Raxol v0.2.0)

View Source

Facade for the Terminal Commands functionality that maintains backward compatibility.

This module provides the same interface as the original CommandExecutor module but delegates to the refactored sub-modules. This allows for a smooth transition while code that depends on the original API is updated.

DEPRECATED: This module is provided for backward compatibility only. New code should use the appropriate sub-modules directly:

  • Raxol.Terminal.Commands.Executor - Main entry point for executing commands
  • Raxol.Terminal.Commands.Parser - For parsing command parameters
  • Raxol.Terminal.Commands.Modes - For handling terminal mode setting/resetting
  • Raxol.Terminal.Commands.Screen - For screen manipulation operations
  • Raxol.Terminal.Commands.History - For command history management

Summary

Functions

Adds a command to the history.

Clears a line or part of a line based on the mode parameter.

Clears the screen or a part of it based on the mode parameter.

Deletes lines at the current cursor position.

Executes a CSI (Control Sequence Introducer) command.

Gets a parameter at a specific index from the params list.

Handles ANSI mode setting or resetting.

Handles DEC private mode setting or resetting.

Inserts blank lines at the current cursor position.

Creates a new command history manager.

Parses a raw parameter string buffer into a list of integers or nil values.

Retrieves the previous command in history.

Functions

add_to_history(history, command)

Adds a command to the history.

This method delegates to the Commands.History module.

Parameters

  • history - The history manager struct
  • command - The command to add

Returns

  • Updated history manager struct

Migration Path

Update your code to use the History module directly:

# Before
history = Raxol.Terminal.CommandHistory.add(history, "ls -la")

# After
history = Raxol.Terminal.Commands.History.add(history, "ls -la")

clear_line(emulator, mode)

Clears a line or part of a line based on the mode parameter.

This method delegates to the Commands.Screen module.

Parameters

  • emulator - The current emulator state
  • mode - The mode parameter (0, 1, or 2)

Returns

  • Updated emulator state

Migration Path

Update your code to use the Screen module directly:

# Before
new_emulator = Raxol.Terminal.CommandExecutor.clear_line(emulator, 2)

# After
new_emulator = Raxol.Terminal.Commands.Screen.clear_line(emulator, 2)

clear_screen(emulator, mode)

Clears the screen or a part of it based on the mode parameter.

This method delegates to the Commands.Screen module.

Parameters

  • emulator - The current emulator state
  • mode - The mode parameter (0, 1, 2, or 3)

Returns

  • Updated emulator state

Migration Path

Update your code to use the Screen module directly:

# Before
new_emulator = Raxol.Terminal.CommandExecutor.clear_screen(emulator, 2)

# After
new_emulator = Raxol.Terminal.Commands.Screen.clear_screen(emulator, 2)

delete_line(emulator, count)

Deletes lines at the current cursor position.

This method delegates to the Commands.Screen module.

Parameters

  • emulator - The current emulator state
  • count - The number of lines to delete

Returns

  • Updated emulator state

Migration Path

Update your code to use the Screen module directly:

# Before
new_emulator = Raxol.Terminal.CommandExecutor.delete_line(emulator, 2)

# After
new_emulator = Raxol.Terminal.Commands.Screen.delete_lines(emulator, 2)

execute_csi_command(emulator, params_buffer, intermediates_buffer, final_byte)

Executes a CSI (Control Sequence Introducer) command.

This method delegates to the Commands.Executor module for the actual execution.

Parameters

  • emulator - The current emulator state
  • params_buffer - The parameter portion of the CSI sequence
  • intermediates_buffer - The intermediate bytes portion of the CSI sequence
  • final_byte - The final byte that determines the specific command

Returns

  • Updated emulator state

Migration Path

Update your code to use the Executor module directly:

# Before
new_emulator = Raxol.Terminal.CommandExecutor.execute_csi_command(emulator, params, intermediates, final_byte)

# After
new_emulator = Raxol.Terminal.Commands.Executor.execute_csi_command(emulator, params, intermediates, final_byte)

get_param(params, index, default \\ 1)

Gets a parameter at a specific index from the params list.

This method delegates to the Commands.Parser module.

Parameters

  • params - The list of parsed parameters
  • index - The index to get the parameter from
  • default - The default value to return if the parameter is nil or out of bounds

Returns

  • The parameter value or the default value

Migration Path

Update your code to use the Parser module directly:

# Before
value = Raxol.Terminal.CommandExecutor.get_param(params, 1, 0)

# After
value = Raxol.Terminal.Commands.Parser.get_param(params, 1, 0)

handle_ansi_mode(emulator, params, action)

Handles ANSI mode setting or resetting.

This method delegates to the Commands.Modes module.

Parameters

  • emulator - The current emulator state
  • params - The parsed parameters
  • action - The action to perform (:set or :reset)

Returns

  • Updated emulator state

Migration Path

Update your code to use the Modes module directly:

# Before
new_emulator = Raxol.Terminal.CommandExecutor.handle_ansi_mode(emulator, params, :set)

# After
new_emulator = Raxol.Terminal.Commands.Modes.handle_ansi_mode(emulator, params, :set)

handle_dec_private_mode(emulator, params, action)

Handles DEC private mode setting or resetting.

This method delegates to the Commands.Modes module.

Parameters

  • emulator - The current emulator state
  • params - The parsed parameters
  • action - The action to perform (:set or :reset)

Returns

  • Updated emulator state

Migration Path

Update your code to use the Modes module directly:

# Before
new_emulator = Raxol.Terminal.CommandExecutor.handle_dec_private_mode(emulator, params, :set)

# After
new_emulator = Raxol.Terminal.Commands.Modes.handle_dec_private_mode(emulator, params, :set)

insert_line(emulator, count)

Inserts blank lines at the current cursor position.

This method delegates to the Commands.Screen module.

Parameters

  • emulator - The current emulator state
  • count - The number of lines to insert

Returns

  • Updated emulator state

Migration Path

Update your code to use the Screen module directly:

# Before
new_emulator = Raxol.Terminal.CommandExecutor.insert_line(emulator, 2)

# After
new_emulator = Raxol.Terminal.Commands.Screen.insert_lines(emulator, 2)

new_history(max_size)

Creates a new command history manager.

This method delegates to the Commands.History module.

Parameters

  • max_size - The maximum number of commands to store

Returns

  • A new history manager struct

Migration Path

Update your code to use the History module directly:

# Before
history = Raxol.Terminal.CommandHistory.new(1000)

# After
history = Raxol.Terminal.Commands.History.new(1000)

parse_params(params_string)

Parses a raw parameter string buffer into a list of integers or nil values.

This method delegates to the Commands.Parser module for the actual parsing.

Parameters

  • params_string - The raw parameter string from a CSI sequence

Returns

  • A list of parsed parameters

Migration Path

Update your code to use the Parser module directly:

# Before
params = Raxol.Terminal.CommandExecutor.parse_params(params_string)

# After
params = Raxol.Terminal.Commands.Parser.parse_params(params_string)

previous_command(history)

Retrieves the previous command in history.

This method delegates to the Commands.History module.

Parameters

  • history