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

Copy Markdown 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)

Appends data to the buffer.

backspace(buffer)

Removes the last character from the buffer (backspace).

clear(buffer)

Clears the buffer contents.

delete_first(buffer)

Removes the first character from the buffer.

empty?(input_buffer)

Checks if the buffer is empty.

get_contents(input_buffer)

Gets the current contents of the buffer.

insert_at(buffer, position, char)

Inserts a character at the specified position.

max_size(input_buffer)

Gets the maximum size of the buffer.

new()

Creates a new input buffer with default values.

new(max_size, overflow_mode)

Creates a new input buffer with custom max_size and overflow_mode.

overflow_mode(input_buffer)

Gets the overflow mode of the buffer.

prepend(buffer, new_data)

Prepends data to the buffer.

replace_at(buffer, position, char)

Replaces a character at the specified position.

set_contents(buffer, new_contents)

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

set_max_size(buffer, new_max_size)

Sets the maximum size of the buffer.

set_overflow_mode(buffer, new_overflow_mode)

Sets the overflow mode of the buffer.

size(input_buffer)

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