Raxol.Terminal.Command.Manager (Raxol v0.4.0)

View Source

Manages terminal command history and processing, including command buffer, history, and command execution.

Summary

Functions

Adds a command to the history, maintaining the maximum history size.

Clears the command history.

Gets the current command buffer.

Gets the command history.

Gets a command from history by index (0-based). Returns nil if index is out of bounds.

Gets the last key event.

Creates a new command manager with default values.

Processes a key event and updates the command buffer accordingly. Returns {new_manager, command_to_execute} where command_to_execute is nil if no command should be executed.

Searches command history for commands matching the given prefix. Returns a list of matching commands.

Updates the current command buffer.

Updates the last key event.

Updates the maximum command history size. If the new size is smaller than the current history, older commands are removed.

Types

t()

@type t() :: %Raxol.Terminal.Command.Manager{
  command_history: [String.t()],
  current_command_buffer: String.t(),
  last_key_event: map() | nil,
  max_command_history: non_neg_integer()
}

Functions

add_to_history(manager, command)

Adds a command to the history, maintaining the maximum history size.

clear_history(manager)

Clears the command history.

get_command_buffer(manager)

Gets the current command buffer.

get_command_history(manager)

Gets the command history.

get_history_command(manager, index)

Gets a command from history by index (0-based). Returns nil if index is out of bounds.

get_last_key_event(manager)

Gets the last key event.

new(opts \\ [])

Creates a new command manager with default values.

process_key_event(manager, key_event)

Processes a key event and updates the command buffer accordingly. Returns {new_manager, command_to_execute} where command_to_execute is nil if no command should be executed.

search_history(manager, prefix)

Searches command history for commands matching the given prefix. Returns a list of matching commands.

update_command_buffer(manager, buffer)

Updates the current command buffer.

update_last_key_event(manager, event)

Updates the last key event.

update_max_history(manager, new_size)

Updates the maximum command history size. If the new size is smaller than the current history, older commands are removed.