Raxol.Terminal.Buffer.State (Raxol v0.3.0)

View Source

Handles state management and accessors for the Raxol.Terminal.ScreenBuffer. Includes resizing, getting dimensions, accessing cells/lines, managing scroll regions, and getting content.

Summary

Functions

Clears the scroll region setting in the buffer.

Gets a specific Cell from the buffer at {x, y}. Returns nil if coordinates are out of bounds.

Gets the cell at the specified coordinates {x, y}. Returns nil if coordinates are out of bounds. Alias for get_cell/3.

Converts the screen buffer content to a plain text string.

Gets the dimensions {width, height} of the screen buffer.

Gets the current height of the screen buffer.

Gets a specific line (list of Cells) from the buffer by index. Returns nil if index is out of bounds.

Gets the boundaries {top, bottom} of the current scroll region. Returns {0, height - 1} if no region is set.

Gets the current width of the screen buffer.

Resizes the screen buffer to the new dimensions. Preserves content that fits within the new bounds. Clears selection and scroll region.

Sets a scroll region in the buffer.

Functions

clear_scroll_region(buffer)

Clears the scroll region setting in the buffer.

get_cell(buffer, x, y)

Gets a specific Cell from the buffer at {x, y}. Returns nil if coordinates are out of bounds.

get_cell_at(buffer, x, y)

Gets the cell at the specified coordinates {x, y}. Returns nil if coordinates are out of bounds. Alias for get_cell/3.

get_content(buffer)

@spec get_content(Raxol.Terminal.ScreenBuffer.t()) :: String.t()

Converts the screen buffer content to a plain text string.

get_dimensions(buffer)

Gets the dimensions {width, height} of the screen buffer.

get_height(buffer)

Gets the current height of the screen buffer.

get_line(buffer, line_index)

Gets a specific line (list of Cells) from the buffer by index. Returns nil if index is out of bounds.

get_scroll_region_boundaries(buffer)

@spec get_scroll_region_boundaries(Raxol.Terminal.ScreenBuffer.t()) ::
  {non_neg_integer(), non_neg_integer()}

Gets the boundaries {top, bottom} of the current scroll region. Returns {0, height - 1} if no region is set.

get_width(buffer)

Gets the current width of the screen buffer.

resize(buffer, new_width, new_height)

Resizes the screen buffer to the new dimensions. Preserves content that fits within the new bounds. Clears selection and scroll region.

set_scroll_region(buffer, start_line, end_line)

Sets a scroll region in the buffer.