Raxol.Terminal.Buffer (Raxol v2.0.1)
View SourceManages the terminal buffer state and operations.
Summary
Functions
Adds content to the buffer at the current cursor position.
Clears the buffer.
Clear a rectangular region in the buffer.
Draw a box in the buffer with the specified style.
Fills a region of the buffer with a specified cell. Delegates to ScreenBuffer.fill_region/6.
Gets a cell from the buffer at the specified coordinates. Delegates to ScreenBuffer.get_cell/3.
Gets the current cursor position.
Gets all damaged regions in the buffer.
Marks a region of the buffer as damaged.
Move the cursor to the specified position.
Creates a new buffer with default dimensions (80x24).
Creates a new buffer with the specified dimensions. Raises ArgumentError if dimensions are invalid.
Reads data from the buffer.
Resizes the buffer to the specified width and height. Delegates to ScreenBuffer.resize/3.
Scrolls the buffer by the specified number of lines.
Updates the scroll state without moving content. This is a fast operation that only updates scroll position.
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.
Writes text to the buffer at the current 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.
Clear a rectangular region in the buffer.
Draw a box in the buffer with the specified style.
@spec fill_region( t(), non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer(), Raxol.Terminal.Buffer.Cell.t() ) :: t()
Fills a region of the buffer with a specified cell. Delegates to ScreenBuffer.fill_region/6.
@spec get_cell(t(), non_neg_integer(), non_neg_integer()) :: Raxol.Terminal.Buffer.Cell.t()
Gets a cell from the buffer at the specified coordinates. Delegates to ScreenBuffer.get_cell/3.
@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.
Move the cursor to the specified position.
@spec new() :: t()
Creates a new buffer with default dimensions (80x24).
@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.
@spec resize(t(), non_neg_integer(), non_neg_integer()) :: t()
Resizes the buffer to the specified width and height. Delegates to ScreenBuffer.resize/3.
Scrolls the buffer by the specified number of lines.
Updates the scroll state without moving content. This is a fast operation that only updates scroll position.
@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.
Writes text to the buffer at the current position.