ExRatatui.CellSession.Snapshot (ExRatatui v0.18.0)

Copy Markdown View Source

Full-buffer snapshot returned by ExRatatui.CellSession.take_cells/1.

Carries the dimensions of the buffer plus every cell, in row-major order — cells has length width * height. Use this when the complete picture is needed: initial paint after a fresh client connects, one-off screenshot, regression test fixture.

For streaming updates use ExRatatui.CellSession.take_cells_diff/1 instead, which returns the same Cell shape inside an ExRatatui.CellSession.Diff payload but only includes cells that changed since the last diff call.

Fields

  • :width — terminal width in cells
  • :height — terminal height in cells
  • :cells — list of ExRatatui.CellSession.Cell.t/0 in row-major order: (0,0), (1,0), ..., (W-1,0), (0,1), ...
  • :regions — list of ExRatatui.CellSession.Region.t/0, the pixel regions on screen (bitmaps from pixel-mode widgets). Always empty for a session created without a :font_size.

Examples

iex> %ExRatatui.CellSession.Snapshot{}
%ExRatatui.CellSession.Snapshot{width: 0, height: 0, cells: [], regions: []}

Summary

Functions

Builds a t/0 from the raw %{width, height, cells, regions} map the NIF returns. Each tuple in cells is converted via ExRatatui.CellSession.Cell.from_tuple/1, each map in regions via ExRatatui.CellSession.Region.from_native/1. regions is the complete list of pixel regions on screen (always empty for a session created without a :font_size).

Types

t()

@type t() :: %ExRatatui.CellSession.Snapshot{
  cells: [ExRatatui.CellSession.Cell.t()],
  height: non_neg_integer(),
  regions: [ExRatatui.CellSession.Region.t()],
  width: non_neg_integer()
}

Functions

from_native(native)

@spec from_native(%{
  :width => non_neg_integer(),
  :height => non_neg_integer(),
  :cells => [tuple()],
  optional(:regions) => [map()]
}) :: t()

Builds a t/0 from the raw %{width, height, cells, regions} map the NIF returns. Each tuple in cells is converted via ExRatatui.CellSession.Cell.from_tuple/1, each map in regions via ExRatatui.CellSession.Region.from_native/1. regions is the complete list of pixel regions on screen (always empty for a session created without a :font_size).