Raxol.Terminal.Buffer (Raxol v0.5.0)
View SourceManages the terminal buffer state and operations.
Summary
Functions
Adds content to the buffer at the current cursor position.
Clears the buffer.
Gets the current cursor position.
Gets all damaged regions in the buffer.
Marks a region of the buffer as damaged.
Creates a new buffer with the specified dimensions. Raises ArgumentError if dimensions are invalid.
Reads data from the buffer.
Scrolls the buffer by the specified number of lines.
Sets a cell in the buffer at the specified coordinates. Raises ArgumentError if coordinates or cell data are invalid.
Sets the cursor position.
Sets the scroll region.
Writes data to the buffer at the current cursor position.
Types
@type t() :: %Raxol.Terminal.Buffer{ cells: [[Raxol.Terminal.Buffer.Cell.t()]], cursor_x: non_neg_integer(), cursor_y: non_neg_integer(), damage_regions: [ {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()} ], height: non_neg_integer(), scroll_region_bottom: non_neg_integer(), scroll_region_top: non_neg_integer(), width: non_neg_integer() }
Functions
Adds content to the buffer at the current cursor position.
Examples
iex> buffer = Buffer.new({80, 24})
iex> buffer = Buffer.add(buffer, "Hello, World!")
iex> {content, _} = Buffer.read(buffer)
iex> content
"Hello, World!"
Clears the buffer.
@spec get_cursor_position(t()) :: {non_neg_integer(), non_neg_integer()}
Gets the current cursor position.
@spec get_damage_regions(t()) :: [ {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()} ]
Gets all damaged regions in the buffer.
@spec mark_damaged( t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer() ) :: t()
Marks a region of the buffer as damaged.
@spec new({non_neg_integer(), non_neg_integer()}) :: t()
Creates a new buffer with the specified dimensions. Raises ArgumentError if dimensions are invalid.
Reads data from the buffer.
Scrolls the buffer by the specified number of lines.
@spec set_cell( t(), non_neg_integer(), non_neg_integer(), Raxol.Terminal.Buffer.Cell.t() ) :: t()
Sets a cell in the buffer at the specified coordinates. Raises ArgumentError if coordinates or cell data are invalid.
@spec set_cursor_position(t(), non_neg_integer(), non_neg_integer()) :: t()
Sets the cursor position.
@spec set_scroll_region(t(), non_neg_integer(), non_neg_integer()) :: t()
Sets the scroll region.
Writes data to the buffer at the current cursor position.