Raxol.Terminal.ScreenBuffer (Raxol v2.3.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

Functions

Creates a new screen buffer with the specified dimensions. Validates and normalizes the input dimensions to ensure they are valid.

Types

t()

@type t() :: %Raxol.Terminal.ScreenBuffer{
  alternate_screen: boolean(),
  cells: [[Raxol.Terminal.Cell.t()]],
  cursor_blink: boolean(),
  cursor_position: {non_neg_integer(), non_neg_integer()},
  cursor_style: atom(),
  cursor_visible: boolean(),
  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_position: 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

cleanup(buffer)

clear(buffer, style \\ nil)

clear_damaged_regions(buffer)

clear_line(buffer, line, style)

See Raxol.Terminal.ScreenBuffer.Operations.clear_line/3.

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

clear_selection(buffer)

See Raxol.Terminal.ScreenBuffer.Selection.clear_selection/1.

cursor_blinking?(buffer)

See Raxol.Terminal.ScreenBuffer.Attributes.cursor_blinking?/1.

cursor_visible?(buffer)

See Raxol.Terminal.ScreenBuffer.Attributes.cursor_visible?/1.

delete_characters(buffer, row, col, count, default_style)

delete_chars(buffer, count)

See Raxol.Terminal.ScreenBuffer.Operations.delete_chars/2.

delete_chars(buffer, count, cursor, max_col)

delete_lines(buffer, count)

See Raxol.Terminal.ScreenBuffer.Operations.delete_lines/2.

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

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

See Raxol.Terminal.Buffer.LineOperations.delete_lines_in_region/5.

erase_chars(buffer, count)

See Raxol.Terminal.ScreenBuffer.Operations.erase_chars/2.

erase_chars(buffer, x, y, count)

See Raxol.Terminal.ScreenBuffer.Operations.erase_chars/4.

erase_display(buffer, mode)

See Raxol.Terminal.ScreenBuffer.Operations.erase_display/2.

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

erase_from_cursor_to_end(buffer, x, y, top, bottom)

erase_from_start_to_cursor(buffer, x, y, top, bottom)

erase_in_display(buffer, position, type)

erase_in_line(buffer, position, type)

erase_line(buffer, mode)

See Raxol.Terminal.ScreenBuffer.Operations.erase_line/2.

erase_line(buffer, line, mode)

See Raxol.Terminal.ScreenBuffer.Operations.erase_line/3.

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

erase_screen(buffer)

fill_region(buffer, x, y, width, height, cell)

See Raxol.Terminal.ScreenBuffer.RegionOperations.fill_region/6.

get_cell_at(buffer, x, y)

get_content(buffer)

get_cursor_position(buffer)

See Raxol.Terminal.ScreenBuffer.Attributes.get_cursor_position/1.

get_cursor_style(buffer)

See Raxol.Terminal.ScreenBuffer.Attributes.get_cursor_style/1.

get_damaged_regions(buffer)

get_line(buffer, y)

get_lines(arg1)

get_scroll_bottom(buffer)

get_scroll_region(buffer)

get_scroll_top(buffer)

get_scrollback(buffer)

get_selected_text(buffer)

See Raxol.Terminal.ScreenBuffer.Selection.get_selected_text/1.

get_selection(buffer)

get_selection_boundaries(buffer)

See Raxol.Terminal.ScreenBuffer.Selection.get_selection_boundaries/1.

get_selection_end(buffer)

See Raxol.Terminal.ScreenBuffer.Selection.get_selection_end/1.

get_selection_start(buffer)

See Raxol.Terminal.ScreenBuffer.Selection.get_selection_start/1.

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

See Raxol.Terminal.ScreenBuffer.Attributes.get_text_in_region/5.

handle_single_line_replacement(lines_list, row, start_col, end_col, replacement)

See Raxol.Terminal.ScreenBuffer.RegionOperations.handle_single_line_replacement/5.

in_selection?(buffer, x, y)

insert_chars(buffer, count)

See Raxol.Terminal.ScreenBuffer.Operations.insert_chars/2.

insert_chars(buffer, count, cursor, max_col)

insert_lines(buffer, count)

See Raxol.Terminal.ScreenBuffer.Operations.insert_lines/2.

insert_lines(buffer, y, count, style)

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

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

new()

new(size)

new(width, height, scrollback_limit \\ 1000)

Creates a new screen buffer with the specified dimensions. Validates and normalizes the input dimensions to ensure they are valid.

pop_bottom_lines(buffer, count)

prepend_lines(buffer, lines)

See Raxol.Terminal.ScreenBuffer.Operations.prepend_lines/2.

put_line(buffer, y, line)

reset_charset_state(buffer)

See Raxol.Terminal.ScreenBuffer.Attributes.reset_charset_state/1.

reset_scroll_region(buffer)

resize(buffer, new_width, new_height)

scroll(buffer, lines)

scroll_down(buffer, lines, count)

scroll_down(buffer, top, bottom, lines)

scroll_to(buffer, top, bottom, line)

scroll_up(buffer, top, bottom, lines)

selection_active?(buffer)

See Raxol.Terminal.ScreenBuffer.Selection.selection_active?/1.

set_cursor_blink(buffer, blink)

See Raxol.Terminal.ScreenBuffer.Attributes.set_cursor_blink/2.

set_cursor_position(buffer, x, y)

See Raxol.Terminal.ScreenBuffer.Attributes.set_cursor_position/3.

set_cursor_style(buffer, style)

See Raxol.Terminal.ScreenBuffer.Attributes.set_cursor_style/2.

set_cursor_visibility(buffer, visible)

See Raxol.Terminal.ScreenBuffer.Attributes.set_cursor_visibility/2.

set_dimensions(buffer, width, height)

set_scroll_region(buffer, arg)

set_scrollback(buffer, scrollback)

shift_region_to_line(buffer, region, target_line)

start_selection(buffer, x, y)

See Raxol.Terminal.ScreenBuffer.Selection.start_selection/3.

update(buffer, changes)

update_selection(buffer, x, y)

See Raxol.Terminal.ScreenBuffer.Selection.update_selection/3.

write(buffer, string, opts)

write(buffer, x, y, content)

write_char(buffer, x, y, char)

write_string(buffer, x, y, string)