Raxol.Terminal.Input.InputBuffer (Raxol v2.0.1)
View SourceA simple data structure for managing input buffer state.
This module provides a stateless API for managing input buffer data, separate from the GenServer-based Buffer module that handles process-based buffering.
Summary
Functions
Appends data to the buffer.
Removes the last character from the buffer (backspace).
Clears the buffer contents.
Removes the first character from the buffer.
Checks if the buffer is empty.
Gets the current contents of the buffer.
Inserts a character at the specified position.
Gets the maximum size of the buffer.
Creates a new input buffer with default values.
Creates a new input buffer with custom max_size and overflow_mode.
Gets the overflow mode of the buffer.
Prepends data to the buffer.
Replaces a character at the specified position.
Sets the contents of the buffer, handling overflow according to the buffer's mode.
Sets the maximum size of the buffer.
Sets the overflow mode of the buffer.
Gets the current size (byte count) of the buffer contents.
Types
@type overflow_mode() :: :truncate | :wrap | :error
@type t() :: %Raxol.Terminal.Input.InputBuffer{ contents: binary(), max_size: non_neg_integer(), overflow_mode: overflow_mode() }
Functions
Appends data to the buffer.
Removes the last character from the buffer (backspace).
Clears the buffer contents.
Removes the first character from the buffer.
Checks if the buffer is empty.
Gets the current contents of the buffer.
@spec insert_at(t(), non_neg_integer(), binary()) :: t()
Inserts a character at the specified position.
@spec max_size(t()) :: non_neg_integer()
Gets the maximum size of the buffer.
@spec new() :: t()
Creates a new input buffer with default values.
@spec new(non_neg_integer(), overflow_mode()) :: t()
Creates a new input buffer with custom max_size and overflow_mode.
@spec overflow_mode(t()) :: overflow_mode()
Gets the overflow mode of the buffer.
Prepends data to the buffer.
@spec replace_at(t(), non_neg_integer(), binary()) :: t()
Replaces a character at the specified position.
Sets the contents of the buffer, handling overflow according to the buffer's mode.
@spec set_max_size(t(), non_neg_integer()) :: t()
Sets the maximum size of the buffer.
@spec set_overflow_mode(t(), overflow_mode()) :: t()
Sets the overflow mode of the buffer.
@spec size(t()) :: non_neg_integer()
Gets the current size (byte count) of the buffer contents.