Raxol.Terminal.Buffer.Manager.State (Raxol v0.4.0)

View Source

Handles state management for the terminal buffer manager. Provides functionality for initializing and managing buffer state.

Summary

Functions

Gets the current dimensions of the buffer.

Gets the scrollback height.

Creates a new buffer manager state with the given dimensions.

Switches the active and back buffers.

Updates the active buffer in the state.

Updates the back buffer in the state.

Types

t()

@type t() :: %Raxol.Terminal.Buffer.Manager.State{
  active_buffer: Raxol.Terminal.ScreenBuffer.t(),
  back_buffer: Raxol.Terminal.ScreenBuffer.t(),
  cursor_position: {non_neg_integer(), non_neg_integer()},
  damage_tracker: Raxol.Terminal.Buffer.DamageTracker.t(),
  memory_limit: non_neg_integer(),
  memory_usage: non_neg_integer(),
  scrollback: Raxol.Terminal.Buffer.Scrollback.t()
}

Functions

get_dimensions(state)

Gets the current dimensions of the buffer.

get_scrollback_height(state)

Gets the scrollback height.

new(width, height, scrollback_height \\ 1000, memory_limit \\ 10_000_000)

Creates a new buffer manager state with the given dimensions.

Examples

iex> {:ok, state} = State.new(80, 24)
iex> state.active_buffer.width
80
iex> state.active_buffer.height
24

switch_buffers(state)

Switches the active and back buffers.

Examples

iex> state = State.new(80, 24)
iex> state = State.switch_buffers(state)
iex> state.active_buffer == state.back_buffer
false

update_active_buffer(state, new_buffer)

Updates the active buffer in the state.

update_back_buffer(state, new_buffer)

Updates the back buffer in the state.