Raxol.Terminal.ScreenBuffer (Raxol v0.2.0)

View Source

Manages the terminal's screen buffer state (grid, scrollback, selection). Delegates operations to specialized modules in Raxol.Terminal.Buffer.*

Summary

Functions

Creates a new screen buffer with the specified dimensions.

Types

t()

@type t() :: %Raxol.Terminal.ScreenBuffer{
  cells: [[Raxol.Terminal.Cell.t()]],
  height: non_neg_integer(),
  scroll_region: {integer(), integer()} | nil,
  scrollback: [[Raxol.Terminal.Cell.t()]],
  scrollback_limit: non_neg_integer(),
  selection: {integer(), integer(), integer(), integer()} | nil,
  width: non_neg_integer()
}

Functions

clear(buffer)

@spec clear(t()) :: t()

Clears buffer. See Raxol.Terminal.Buffer.Operations.clear/1.

clear_region(buffer, start_x, start_y, end_x, end_y)

@spec clear_region(
  t(),
  non_neg_integer(),
  non_neg_integer(),
  non_neg_integer(),
  non_neg_integer()
) :: t()

Clears region. See Raxol.Terminal.Buffer.Operations.clear_region/5.

clear_scroll_region(buffer)

@spec clear_scroll_region(t()) :: t()

Clears scroll region. See Raxol.Terminal.Buffer.Operations.clear_scroll_region/1.

delete_characters(buffer, pos, count)

@spec delete_characters(
  t(),
  {non_neg_integer(), non_neg_integer()},
  non_neg_integer()
) :: t()

Deletes characters. See Raxol.Terminal.Buffer.Operations.delete_characters/3.

delete_lines(buffer, start_y, n, scroll_region)

@spec delete_lines(
  t(),
  non_neg_integer(),
  non_neg_integer(),
  {non_neg_integer(), non_neg_integer()} | nil
) :: t()

Deletes lines. See Raxol.Terminal.Buffer.Operations.delete_lines/4.

diff(buffer, changes)

@spec diff(t(), [{non_neg_integer(), non_neg_integer(), map()}]) :: [
  {non_neg_integer(), non_neg_integer(), map()}
]

Calculates diff. See Raxol.Terminal.Buffer.Operations.diff/2.

erase_in_display(buffer, cursor_pos, type)

@spec erase_in_display(t(), {non_neg_integer(), non_neg_integer()}, atom()) :: t()

Erases in display. See Raxol.Terminal.Buffer.Operations.erase_in_display/3.

erase_in_line(buffer, cursor_pos, type)

@spec erase_in_line(t(), {non_neg_integer(), non_neg_integer()}, atom()) :: t()

Erases in line. See Raxol.Terminal.Buffer.Operations.erase_in_line/3.

get_cell(buffer, x, y)

@spec get_cell(t(), non_neg_integer(), non_neg_integer()) ::
  Raxol.Terminal.Cell.t() | nil

Gets cell. See Raxol.Terminal.Buffer.Operations.get_cell/3.

get_cell_at(buffer, x, y)

@spec get_cell_at(t(), non_neg_integer(), non_neg_integer()) ::
  Raxol.Terminal.Cell.t() | nil

Gets cell at. See Raxol.Terminal.Buffer.Operations.get_cell_at/3.

get_content(buffer)

@spec get_content(t()) :: String.t()

Gets content as string. See Raxol.Terminal.Buffer.Operations.get_content/1.

get_dimensions(buffer)

@spec get_dimensions(t()) :: {non_neg_integer(), non_neg_integer()}

Gets dimensions. See Raxol.Terminal.Buffer.Operations.get_dimensions/1.

get_height(buffer)

@spec get_height(t()) :: non_neg_integer()

Gets height. See Raxol.Terminal.Buffer.Operations.get_height/1.

get_line(buffer, line_index)

@spec get_line(t(), non_neg_integer()) :: [Raxol.Terminal.Cell.t()] | nil

Gets line. See Raxol.Terminal.Buffer.Operations.get_line/2.

get_scroll_position(buffer)

@spec get_scroll_position(t()) :: non_neg_integer()

Gets scrollback size. See Raxol.Terminal.Buffer.Scrollback.size/1.

get_scroll_region_boundaries(buffer)

@spec get_scroll_region_boundaries(t()) :: {non_neg_integer(), non_neg_integer()}

Gets scroll region boundaries. See Raxol.Terminal.Buffer.Operations.get_scroll_region_boundaries/1.

get_selection(buffer)

@spec get_selection(t()) :: String.t()

Gets selected text. See Raxol.Terminal.Buffer.Selection.get_text/1.

get_selection_boundaries(buffer)

@spec get_selection_boundaries(t()) ::
  {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()}
  | nil

Gets selection boundaries. See Raxol.Terminal.Buffer.Selection.get_boundaries/1.

get_text_in_region(buffer, start_x, start_y, end_x, end_y)

@spec get_text_in_region(
  t(),
  non_neg_integer(),
  non_neg_integer(),
  non_neg_integer(),
  non_neg_integer()
) :: String.t()

Gets text in region. See Raxol.Terminal.Buffer.Selection.get_text_in_region/5.

get_width(buffer)

@spec get_width(t()) :: non_neg_integer()

Gets width. See Raxol.Terminal.Buffer.Operations.get_width/1.

in_selection?(buffer, x, y)

@spec in_selection?(t(), non_neg_integer(), non_neg_integer()) :: boolean()

Checks if in selection. See Raxol.Terminal.Buffer.Selection.contains?/3.

insert_characters(buffer, pos, count, style \\ nil)

Inserts characters. See Raxol.Terminal.Buffer.Operations.insert_characters/4.

insert_lines(buffer, start_y, n, scroll_region)

@spec insert_lines(
  t(),
  non_neg_integer(),
  non_neg_integer(),
  {non_neg_integer(), non_neg_integer()} | nil
) :: t()

Inserts lines. See Raxol.Terminal.Buffer.Operations.insert_lines/4.

new(width, height, scrollback_limit \\ 1000)

Creates a new screen buffer with the specified dimensions.

resize(buffer, new_width, new_height)

@spec resize(t(), non_neg_integer(), non_neg_integer()) :: t()

Resizes buffer. See Raxol.Terminal.Buffer.Operations.resize/3.

scroll_down(buffer, lines, scroll_region \\ nil)

@spec scroll_down(
  t(),
  non_neg_integer(),
  {non_neg_integer(), non_neg_integer()} | nil
) :: t()

Scrolls down. See Raxol.Terminal.Buffer.Operations.scroll_down/3.

scroll_up(buffer, lines, scroll_region \\ nil)

@spec scroll_up(
  t(),
  non_neg_integer(),
  {non_neg_integer(), non_neg_integer()} | nil
) :: t()

Scrolls up. See Raxol.Terminal.Buffer.Operations.scroll_up/3.

set_scroll_region(buffer, start_line, end_line)

@spec set_scroll_region(t(), non_neg_integer(), non_neg_integer()) :: t()

Sets scroll region. See Raxol.Terminal.Buffer.Operations.set_scroll_region/3.

start_selection(buffer, x, y)

@spec start_selection(t(), non_neg_integer(), non_neg_integer()) :: t()

Starts selection. See Raxol.Terminal.Buffer.Selection.start/3.

update(buffer, changes)

@spec update(
  t(),
  [{non_neg_integer(), non_neg_integer(), Raxol.Terminal.Cell.t() | map()}]
) :: t()

Updates buffer from changes. See Raxol.Terminal.Buffer.Operations.update/2.

update_selection(buffer, x, y)

@spec update_selection(t(), non_neg_integer(), non_neg_integer()) :: t()

Updates selection. See Raxol.Terminal.Buffer.Selection.update/3.

write_char(buffer, x, y, char, style \\ nil)

Writes a character. See Raxol.Terminal.Buffer.Operations.write_char/5.

write_string(buffer, x, y, string)

@spec write_string(t(), non_neg_integer(), non_neg_integer(), String.t()) :: t()

Writes a string. See Raxol.Terminal.Buffer.Operations.write_string/4.