Raxol.Protocols.CoreProtocols.BufferOperations protocol (Raxol v2.0.1)

View Source

Protocol for buffer operations across different buffer types. Provides unified interface for screen buffers, text buffers, etc.

Summary

Types

t()

All the types that implement this protocol.

Functions

Clears the buffer or a region of the buffer.

Gets the buffer dimensions.

Reads data from the buffer at the specified position.

Resizes the buffer to new dimensions.

Scrolls the buffer in the specified direction.

Writes data to the buffer at the specified position.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

clear(buffer, region \\ :all)

@spec clear(t(), :all | {integer(), integer(), integer(), integer()}) :: t()

Clears the buffer or a region of the buffer.

get_dimensions(buffer)

@spec get_dimensions(t()) :: {integer(), integer()}

Gets the buffer dimensions.

read(buffer, position)

@spec read(
  t(),
  {integer(), integer()}
) :: any()

Reads data from the buffer at the specified position.

resize(buffer, width, height)

@spec resize(t(), integer(), integer()) :: t()

Resizes the buffer to new dimensions.

scroll(buffer, direction, amount)

@spec scroll(t(), :up | :down | :left | :right, integer()) :: t()

Scrolls the buffer in the specified direction.

write(buffer, position, data)

@spec write(t(), {integer(), integer()}, any()) :: t()

Writes data to the buffer at the specified position.