Raxol.Terminal.HistoryManager (Raxol v2.0.1)

View Source

Manages terminal command history operations including history storage, retrieval, and navigation. This module is responsible for handling all history-related operations in the terminal.

Summary

Functions

Adds a command to the history. Returns the updated emulator.

Clears the command history. Returns the updated emulator.

Gets all commands in history. Returns the list of commands.

Gets the history buffer instance. Returns the history buffer.

Gets the command at the specified index. Returns {:ok, command} or {:error, reason}.

Gets the maximum history size. Returns the maximum number of commands that can be stored.

Gets the current history position. Returns the current position.

Gets the history size. Returns the number of commands in history.

Loads history from a file. Returns {:ok, updated_emulator} or {:error, reason}.

Moves to the next command in history. Returns {:ok, updated_emulator, command} or {:error, reason}.

Moves to the previous command in history. Returns {:ok, updated_emulator, command} or {:error, reason}.

Saves the history to a file. Returns :ok or {:error, reason}.

Sets the maximum history size. Returns the updated emulator.

Sets the history position. Returns the updated emulator.

Updates the history buffer instance. Returns the updated emulator.

Functions

add_command(emulator, command)

Adds a command to the history. Returns the updated emulator.

clear_history(emulator)

Clears the command history. Returns the updated emulator.

get_all_commands(emulator)

@spec get_all_commands(Raxol.Terminal.Emulator.t()) :: [String.t()]

Gets all commands in history. Returns the list of commands.

get_buffer(emulator)

Gets the history buffer instance. Returns the history buffer.

get_command_at(emulator, index)

@spec get_command_at(Raxol.Terminal.Emulator.t(), integer()) ::
  {:ok, String.t()} | {:error, String.t()}

Gets the command at the specified index. Returns {:ok, command} or {:error, reason}.

get_max_size(emulator)

@spec get_max_size(Raxol.Terminal.Emulator.t()) :: non_neg_integer()

Gets the maximum history size. Returns the maximum number of commands that can be stored.

get_position(emulator)

@spec get_position(Raxol.Terminal.Emulator.t()) :: integer()

Gets the current history position. Returns the current position.

get_size(emulator)

Gets the history size. Returns the number of commands in history.

load_from_file(emulator, file_path)

@spec load_from_file(Raxol.Terminal.Emulator.t(), String.t()) ::
  {:ok, Raxol.Terminal.Emulator.t()} | {:error, String.t()}

Loads history from a file. Returns {:ok, updated_emulator} or {:error, reason}.

next_command(emulator)

@spec next_command(Raxol.Terminal.Emulator.t()) ::
  {:ok, Raxol.Terminal.Emulator.t(), String.t()} | {:error, String.t()}

Moves to the next command in history. Returns {:ok, updated_emulator, command} or {:error, reason}.

previous_command(emulator)

@spec previous_command(Raxol.Terminal.Emulator.t()) ::
  {:ok, Raxol.Terminal.Emulator.t(), String.t()} | {:error, String.t()}

Moves to the previous command in history. Returns {:ok, updated_emulator, command} or {:error, reason}.

save_to_file(emulator, file_path)

@spec save_to_file(Raxol.Terminal.Emulator.t(), String.t()) ::
  :ok | {:error, String.t()}

Saves the history to a file. Returns :ok or {:error, reason}.

set_max_size(emulator, size)

Sets the maximum history size. Returns the updated emulator.

set_position(emulator, position)

Sets the history position. Returns the updated emulator.

update_buffer(emulator, buffer)

Updates the history buffer instance. Returns the updated emulator.