Raxol.Terminal.ScreenBuffer (Raxol v0.5.0)

View Source

Manages the terminal's screen buffer state (grid, scrollback, selection). This module serves as the main interface for terminal buffer operations, delegating specific operations to specialized modules in Raxol.Terminal.Buffer.*.

Structure

The buffer consists of:

  • A main grid of cells (the visible screen)
  • A scrollback buffer for history
  • Selection state
  • Scroll region settings
  • Dimensions (width and height)

Operations

The module delegates operations to specialized modules:

  • Content - Writing and content management
  • ScrollRegion - Scroll region and scrolling operations
  • LineOperations - Line manipulation
  • CharEditor - Character editing
  • LineEditor - Line editing
  • Eraser - Clearing operations
  • Selection - Text selection
  • Scrollback - History management
  • Queries - State querying
  • Initializer - Buffer creation and validation
  • Cursor - Cursor state management
  • Charset - Character set management
  • Formatting - Text formatting and styling

Summary

Types

t()

@type t() :: %Raxol.Terminal.ScreenBuffer{
  cells: [[Raxol.Terminal.Cell.t()]],
  cursor_position: {non_neg_integer(), non_neg_integer()},
  damage_regions: [
    {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()}
  ],
  default_style: Raxol.Terminal.ANSI.TextFormatting.text_style(),
  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, style \\ nil)

clear_damaged_regions(buffer)

clear_region(buffer, x, y, width, height)

See Raxol.Terminal.ScreenBuffer.Core.clear_region/5.

delete_chars(buffer, count, cursor, max_col)

delete_lines(buffer, y, count, style, bottom)

Deletes lines at a specific position.

Parameters

  • For command handlers: y, count, style, and region boundaries
  • For region operations: lines, y, top, and bottom positions

erase_display(buffer, mode, cursor, min_row, max_row)

erase_line(buffer, mode, cursor, min_col, max_col)

get_damaged_regions(buffer)

get_scrollback(buffer)

insert_chars(buffer, count, cursor, max_col)

insert_lines(buffer, y, count, style)

Inserts blank lines at a specific position with style.

insert_lines(buffer, lines, y, top, bottom)

Inserts blank lines at a specific position within a region.

mark_damaged(buffer, x, y, width, height, reason)

See Raxol.Terminal.ScreenBuffer.Core.mark_damaged/6.

pop_bottom_lines(buffer, count)

See Raxol.Terminal.ScreenBuffer.Core.pop_bottom_lines/2.

set_dimensions(buffer, width, height)

set_scrollback(buffer, scrollback)