ETee.Scrollback (e_tee v0.1.0)

Copy Markdown View Source

A bounded history of rows that have scrolled off the top of the screen.

Rows are pushed one at a time and read newest-last. The bound is a row count; once it is reached, each push drops the oldest row.

Summary

Functions

Discard every held row.

An empty history holding at most limit rows.

Append a row, dropping the oldest when the limit is reached.

Append several rows, oldest first.

The newest count rows, oldest first.

How many rows are held.

Every held row, oldest first.

Types

t()

@type t() :: %ETee.Scrollback{
  count: non_neg_integer(),
  limit: non_neg_integer(),
  rows: :queue.queue()
}

Functions

clear(history)

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

Discard every held row.

new(limit \\ 1000)

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

An empty history holding at most limit rows.

push(history, row)

@spec push(t(), term()) :: t()

Append a row, dropping the oldest when the limit is reached.

push_many(history, rows)

@spec push_many(t(), [term()]) :: t()

Append several rows, oldest first.

recent(history, count)

@spec recent(t(), non_neg_integer()) :: [term()]

The newest count rows, oldest first.

size(scrollback)

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

How many rows are held.

to_list(scrollback)

@spec to_list(t()) :: [term()]

Every held row, oldest first.