Raxol.Terminal.ScreenBuffer (Raxol v0.3.0)

View Source

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

Summary

Functions

Deletes count characters starting at {row, col}.

Deletes n lines starting at start_y. Optionally operates only within the given scroll_region {top, bottom}.

Gets the character at the specified position. Returns nil if coordinates are out of bounds.

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

Inserts count blank characters at {row, col}.

Inserts count blank lines at row.

Checks if the buffer contains only default cells.

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, default_style)

Clears buffer. See Raxol.Terminal.Buffer.Eraser.clear_screen/2.

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

Clears region. See Raxol.Terminal.Buffer.Eraser.clear_region/6.

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, row, col, count, default_style)

Deletes count characters starting at {row, col}.

Characters to the right are shifted left. Blank cells are inserted at the end of the line.

Delegates to CharEditor.delete_characters/5. Requires default_style.

delete_lines(buffer, start_y, count, default_style, scroll_region \\ nil)

Deletes n lines starting at start_y. Optionally operates only within the given scroll_region {top, bottom}.

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, default_style)

@spec erase_in_display(
  t(),
  {non_neg_integer(), non_neg_integer()},
  atom(),
  Raxol.Terminal.ANSI.TextFormatting.text_style()
) :: t()

Erases in display. See Raxol.Terminal.Buffer.Eraser.erase_in_display/4.

erase_in_line(buffer, cursor_pos, type, default_style)

Erases in line. See Raxol.Terminal.Buffer.Eraser.erase_in_line/4.

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_char(buffer, x, y)

@spec get_char(t(), non_neg_integer(), non_neg_integer()) :: String.t() | nil

Gets the character at the specified position. Returns nil if coordinates are out of bounds.

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, row, col, count, default_style)

Inserts count blank characters at {row, col}.

Characters from col right are shifted right. Characters shifted off the end of the line are discarded.

Delegates to CharEditor.insert_characters/5. Requires default_style.

insert_lines(buffer, row, count, default_style)

Inserts count blank lines at row.

Lines from row down are shifted down. Lines shifted off the bottom are discarded.

Delegates to LineEditor.insert_lines/4. Requires default_style.

is_empty?(buffer)

@spec is_empty?(t()) :: boolean()

Checks if the buffer contains only default cells.

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.