Raxol.Terminal.HistoryManager (Raxol v2.0.1)
View SourceManages 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
@spec add_command(Raxol.Terminal.Emulator.t(), String.t()) :: Raxol.Terminal.Emulator.t()
Adds a command to the history. Returns the updated emulator.
@spec clear_history(Raxol.Terminal.Emulator.t()) :: Raxol.Terminal.Emulator.t()
Clears the command history. Returns the updated emulator.
@spec get_all_commands(Raxol.Terminal.Emulator.t()) :: [String.t()]
Gets all commands in history. Returns the list of commands.
@spec get_buffer(Raxol.Terminal.Emulator.t()) :: Raxol.Terminal.HistoryBuffer.t() | nil
Gets the history buffer instance. Returns the history buffer.
@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}.
@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.
@spec get_position(Raxol.Terminal.Emulator.t()) :: integer()
Gets the current history position. Returns the current position.
@spec get_size(Raxol.Terminal.Emulator.t()) :: non_neg_integer()
Gets the history size. Returns the number of commands in history.
@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}.
@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}.
@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}.
@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}.
@spec set_max_size(Raxol.Terminal.Emulator.t(), non_neg_integer()) :: Raxol.Terminal.Emulator.t()
Sets the maximum history size. Returns the updated emulator.
@spec set_position(Raxol.Terminal.Emulator.t(), integer()) :: Raxol.Terminal.Emulator.t()
Sets the history position. Returns the updated emulator.
@spec update_buffer(Raxol.Terminal.Emulator.t(), Raxol.Terminal.HistoryBuffer.t()) :: Raxol.Terminal.Emulator.t()
Updates the history buffer instance. Returns the updated emulator.