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

View Source

Manages the scrollback buffer lines.

Stores lines scrolled off the top and provides them when scrolling down. Enforces a configurable size limit.

Summary

Functions

Adds new lines to the top of the scrollback buffer.

Clears all lines from the scrollback buffer.

Creates a new scrollback buffer with a given limit.

Gets the current number of lines stored in the scrollback buffer.

Takes a number of lines from the top of the scrollback buffer.

Types

t()

@type t() :: %Raxol.Terminal.Buffer.Scrollback{
  limit: non_neg_integer(),
  lines: [Raxol.Terminal.ScreenBuffer.Line.t()]
}

Functions

add_lines(scrollback, new_lines)

@spec add_lines(t(), [Raxol.Terminal.ScreenBuffer.Line.t()]) :: t()

Adds new lines to the top of the scrollback buffer.

Lines are prepended. The buffer is trimmed to the limit if necessary.

clear(scrollback)

@spec clear(t()) :: t()

Clears all lines from the scrollback buffer.

new(limit \\ 1000)

@spec new(non_neg_integer()) :: t()

Creates a new scrollback buffer with a given limit.

size(scrollback)

@spec size(t()) :: non_neg_integer()

Gets the current number of lines stored in the scrollback buffer.

take_lines(scrollback, count)

@spec take_lines(t(), non_neg_integer()) ::
  {[Raxol.Terminal.ScreenBuffer.Line.t()], t()}

Takes a number of lines from the top of the scrollback buffer.

Used when scrolling down to restore lines. Returns a tuple: {restored_lines, updated_scrollback_state}. Fewer lines than requested may be returned if the buffer is smaller.