Raxol.Terminal.Command.Manager (Raxol v2.0.1)

View Source

Manages terminal command processing and execution. This module is responsible for handling command parsing, validation, and execution.

Summary

Functions

Adds a command to the history.

Returns a specification to start this module under a supervisor.

Clears the command history.

Gets the current command. Returns the current command or nil.

Gets a command from history by index.

Gets the last key event.

Creates a new command manager.

Creates a new command manager with options.

Processes a command string. Returns the updated emulator and any output.

Processes a key event and updates the command buffer accordingly.

Searches command history for a matching command.

Sets the current command. Returns the updated emulator.

Updates the command buffer.

Updates the last key event.

Types

t()

@type t() :: %Raxol.Terminal.Command.Manager{
  command_buffer: String.t(),
  command_history: [String.t()],
  history_index: integer(),
  last_key_event: term()
}

Functions

add_to_history(pid, command)

add_to_history_state(state, command)

Adds a command to the history.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear_command_buffer(pid \\ __MODULE__)

clear_command_history(pid \\ __MODULE__)

clear_history(state)

Clears the command history.

execute_command(pid \\ __MODULE__, command)

get_command_buffer(manager \\ %Raxol.Terminal.Command{})

get_command_history(manager \\ %Raxol.Terminal.Command{})

get_command_state(pid \\ __MODULE__)

get_current(emulator)

@spec get_current(Raxol.Terminal.Emulator.t()) :: String.t() | nil

Gets the current command. Returns the current command or nil.

get_current_command(pid \\ __MODULE__)

get_history_command(state, index)

Gets a command from history by index.

get_last_key_event(state)

Gets the last key event.

handle_manager_cast(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.

handle_manager_info(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_info/2.

new()

@spec new() :: Raxol.Terminal.Command.t()

Creates a new command manager.

new(opts)

@spec new(keyword()) :: Raxol.Terminal.Command.t()

Creates a new command manager with options.

process_command(emulator, command)

@spec process_command(Raxol.Terminal.Emulator.t(), String.t()) ::
  {Raxol.Terminal.Emulator.t(), any()}

Processes a command string. Returns the updated emulator and any output.

process_key_event(state, arg2)

Processes a key event and updates the command buffer accordingly.

search_history(state, pattern)

Searches command history for a matching command.

set_command_state(pid \\ __MODULE__, state)

set_current(emulator, command)

Sets the current command. Returns the updated emulator.

set_current_command(pid \\ __MODULE__, command)

start_link(init_opts \\ [])

update_command_buffer(state, new_buffer)

Updates the command buffer.

update_last_key_event(state, event)

Updates the last key event.