Raxol.Terminal.Buffer.Scroll (Raxol v0.3.0)

View Source

Terminal scroll buffer module.

This module handles the management of terminal scrollback buffers, including:

  • Virtual scrolling implementation
  • Memory-efficient buffer management
  • Scroll position tracking
  • Buffer compression

Summary

Functions

Adds a line to the scroll buffer.

Clears the scroll buffer.

Gets the total height of the scroll buffer.

Gets the current scroll position.

Gets a view of the scroll buffer at the current position.

Creates a new scroll buffer with the given dimensions.

Scrolls the buffer by the given amount.

Types

t()

@type t() :: %Raxol.Terminal.Buffer.Scroll{
  buffer: [[Raxol.Terminal.Cell.t()]],
  compression_ratio: float(),
  height: non_neg_integer(),
  max_height: non_neg_integer(),
  memory_limit: non_neg_integer(),
  memory_usage: non_neg_integer(),
  position: non_neg_integer()
}

Functions

add_line(scroll, line)

Adds a line to the scroll buffer.

Examples

iex> scroll = Scroll.new(1000)
iex> line = [Cell.new("A"), Cell.new("B")]
iex> scroll = Scroll.add_line(scroll, line)
iex> scroll.height
1

clear(scroll)

Clears the scroll buffer.

Examples

iex> scroll = Scroll.new(1000)
iex> line = [Cell.new("A"), Cell.new("B")]
iex> scroll = Scroll.add_line(scroll, line)
iex> scroll = Scroll.clear(scroll)
iex> scroll.height
0

get_height(scroll)

Gets the total height of the scroll buffer.

Examples

iex> scroll = Scroll.new(1000)
iex> line = [Cell.new("A"), Cell.new("B")]
iex> scroll = Scroll.add_line(scroll, line)
iex> Scroll.get_height(scroll)
1

get_position(scroll)

Gets the current scroll position.

Examples

iex> scroll = Scroll.new(1000)
iex> Scroll.get_position(scroll)
0

get_view(scroll, view_height)

Gets a view of the scroll buffer at the current position.

Examples

iex> scroll = Scroll.new(1000)
iex> line = [Cell.new("A"), Cell.new("B")]
iex> scroll = Scroll.add_line(scroll, line)
iex> view = Scroll.get_view(scroll, 10)
iex> length(view)
1

new(max_height, memory_limit \\ 5_000_000)

Creates a new scroll buffer with the given dimensions.

Examples

iex> scroll = Scroll.new(1000)
iex> scroll.max_height
1000
iex> scroll.position
0

scroll(scroll, amount)

Scrolls the buffer by the given amount.

Examples

iex> scroll = Scroll.new(1000)
iex> line = [Cell.new("A"), Cell.new("B")]
iex> scroll = Scroll.add_line(scroll, line)
iex> scroll = Scroll.scroll(scroll, 5)
iex> scroll.position
5