Harlock.Render.Buffer (harlock v0.2.0)

Copy Markdown View Source

A 2D grid of cells of fixed dimensions, returned by Harlock.Test.cells/1.

Cells are stored in a map keyed by {row, col}; missing keys behave as blanks. The map representation keeps construction cheap (no need to pre-fill every cell) and survives sparse frames where most cells are blank.

In tests you'll typically pull this from Harlock.Test.cells/1 to inspect individual cell contents and styles after a render.

Summary

Functions

Enumerate every cell in render order (row-major, top-left to bottom-right), yielding {row, col, cell} tuples. Missing entries are surfaced as blanks so the diff renderer can compare positions without checking presence.

Types

t()

@type t() :: %Harlock.Render.Buffer{
  cells: %{
    required({non_neg_integer(), non_neg_integer()}) => Harlock.Render.Cell.t()
  },
  cols: non_neg_integer(),
  rows: non_neg_integer()
}

Functions

each(buf, fun)

@spec each(t(), ({non_neg_integer(), non_neg_integer(), Harlock.Render.Cell.t()} ->
             any())) :: :ok

Enumerate every cell in render order (row-major, top-left to bottom-right), yielding {row, col, cell} tuples. Missing entries are surfaced as blanks so the diff renderer can compare positions without checking presence.

get(buffer, row, col)

new(rows, cols)

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

put(buf, row, col, cell)