Raxol.Terminal.Buffer.Queries (Raxol v0.5.0)
View SourceHandles buffer state querying operations. This module provides functions for querying the state of the screen buffer, including dimensions, content, and selection state.
Summary
Functions
Checks if the buffer is empty.
Gets a specific cell from the buffer.
Gets the cell at the specified position in the buffer.
Gets the character at the given position in the buffer.
Gets the character at the specified position in the buffer.
Gets the content of the buffer as a list of lines.
Gets the dimensions of the buffer.
Gets the height of the buffer.
Gets a specific line from the buffer.
Gets the text content of a specific line.
Gets the text content of the buffer.
Gets the width of the buffer.
Checks if a position is within the buffer bounds.
Functions
@spec empty?(Raxol.Terminal.ScreenBuffer.t()) :: boolean()
Checks if the buffer is empty.
Parameters
buffer
- The screen buffer to check
Returns
A boolean indicating if the buffer is empty.
Examples
iex> buffer = ScreenBuffer.new(80, 24)
iex> Queries.empty?(buffer)
true
@spec get_cell(Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer()) :: Raxol.Terminal.Cell.t()
Gets a specific cell from the buffer.
@spec get_cell_at( Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer() ) :: Raxol.Terminal.Cell.t()
Gets the cell at the specified position in the buffer.
Parameters
buffer
- The screen buffer to queryx
- The x-coordinate (column)y
- The y-coordinate (row)
Returns
The cell at the specified position, or an empty cell if the position is out of bounds.
Examples
iex> buffer = ScreenBuffer.new(80, 24)
iex> cell = Queries.get_cell_at(buffer, 0, 0)
iex> cell.char
""
Gets the character at the given position in the buffer.
@spec get_char_at( Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer() ) :: String.t()
Gets the character at the specified position in the buffer.
Parameters
buffer
- The screen buffer to queryx
- The x-coordinate (column)y
- The y-coordinate (row)
Returns
The character at the specified position, or a space if the position is out of bounds.
Examples
iex> buffer = ScreenBuffer.new(80, 24)
iex> Queries.get_char_at(buffer, 0, 0)
" "
@spec get_content(Raxol.Terminal.ScreenBuffer.t()) :: [[Raxol.Terminal.Cell.t()]]
Gets the content of the buffer as a list of lines.
@spec get_dimensions(Raxol.Terminal.ScreenBuffer.t()) :: {non_neg_integer(), non_neg_integer()}
Gets the dimensions of the buffer.
@spec get_height(Raxol.Terminal.ScreenBuffer.t()) :: non_neg_integer()
Gets the height of the buffer.
@spec get_line(Raxol.Terminal.ScreenBuffer.t(), non_neg_integer()) :: [ Raxol.Terminal.Cell.t() ]
Gets a specific line from the buffer.
@spec get_line_text(Raxol.Terminal.ScreenBuffer.t(), non_neg_integer()) :: String.t()
Gets the text content of a specific line.
@spec get_text(Raxol.Terminal.ScreenBuffer.t()) :: String.t()
Gets the text content of the buffer.
@spec get_width(Raxol.Terminal.ScreenBuffer.t()) :: non_neg_integer()
Gets the width of the buffer.
@spec in_bounds?( Raxol.Terminal.ScreenBuffer.t(), non_neg_integer(), non_neg_integer() ) :: boolean()
Checks if a position is within the buffer bounds.