Raxol.Terminal.Input.InputBuffer (Raxol v2.0.1)

View Source

A 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

overflow_mode()

@type overflow_mode() :: :truncate | :wrap | :error

t()

@type t() :: %Raxol.Terminal.Input.InputBuffer{
  contents: binary(),
  max_size: non_neg_integer(),
  overflow_mode: overflow_mode()
}

Functions

append(buffer, new_data)

@spec append(t(), binary()) :: t()

Appends data to the buffer.

backspace(buffer)

@spec backspace(t()) :: t()

Removes the last character from the buffer (backspace).

clear(buffer)

@spec clear(t()) :: t()

Clears the buffer contents.

delete_first(buffer)

@spec delete_first(t()) :: t()

Removes the first character from the buffer.

empty?(input_buffer)

@spec empty?(t()) :: boolean()

Checks if the buffer is empty.

get_contents(input_buffer)

@spec get_contents(t()) :: binary()

Gets the current contents of the buffer.

insert_at(buffer, position, char)

@spec insert_at(t(), non_neg_integer(), binary()) :: t()

Inserts a character at the specified position.

max_size(input_buffer)

@spec max_size(t()) :: non_neg_integer()

Gets the maximum size of the buffer.

new()

@spec new() :: t()

Creates a new input buffer with default values.

new(max_size, overflow_mode)

@spec new(non_neg_integer(), overflow_mode()) :: t()

Creates a new input buffer with custom max_size and overflow_mode.

overflow_mode(input_buffer)

@spec overflow_mode(t()) :: overflow_mode()

Gets the overflow mode of the buffer.

prepend(buffer, new_data)

@spec prepend(t(), binary()) :: t()

Prepends data to the buffer.

replace_at(buffer, position, char)

@spec replace_at(t(), non_neg_integer(), binary()) :: t()

Replaces a character at the specified position.

set_contents(buffer, new_contents)

@spec set_contents(t(), binary()) :: t()

Sets the contents of the buffer, handling overflow according to the buffer's mode.

set_max_size(buffer, new_max_size)

@spec set_max_size(t(), non_neg_integer()) :: t()

Sets the maximum size of the buffer.

set_overflow_mode(buffer, new_overflow_mode)

@spec set_overflow_mode(t(), overflow_mode()) :: t()

Sets the overflow mode of the buffer.

size(input_buffer)

@spec size(t()) :: non_neg_integer()

Gets the current size (byte count) of the buffer contents.