Raxol.Terminal.Buffer.Queries (Raxol v0.5.0)

View Source

Handles 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

empty?(buffer)

@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

get_cell(buffer, x, y)

Gets a specific cell from the buffer.

get_cell_at(buffer, x, y)

Gets the cell at the specified position in the buffer.

Parameters

  • buffer - The screen buffer to query
  • x - 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
""

get_char(buffer, x, y)

@spec get_char(map(), integer(), integer()) :: String.t()

Gets the character at the given position in the buffer.

get_char_at(buffer, x, y)

Gets the character at the specified position in the buffer.

Parameters

  • buffer - The screen buffer to query
  • x - 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)
" "

get_content(buffer)

Gets the content of the buffer as a list of lines.

get_dimensions(buffer)

Gets the dimensions of the buffer.

get_height(buffer)

Gets the height of the buffer.

get_line(buffer, y)

Gets a specific line from the buffer.

get_line_text(buffer, y)

@spec get_line_text(Raxol.Terminal.ScreenBuffer.t(), non_neg_integer()) :: String.t()

Gets the text content of a specific line.

get_text(buffer)

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

Gets the text content of the buffer.

get_width(buffer)

Gets the width of the buffer.

in_bounds?(buffer, x, y)

Checks if a position is within the buffer bounds.