Raxol.UI.Layout.Preparer (Raxol v2.6.0)

View Source

Walks an element tree and produces PreparedElements with cached text measurements.

This is the "prepare" phase of the two-phase prepare/layout architecture inspired by Pretext. The prepare phase measures all text nodes and caches the results. The layout phase (LayoutEngine) then uses these cached measurements for pure arithmetic position calculations.

On terminal resize, only the layout phase needs to re-run if text content hasn't changed, since measurements are cached in the PreparedElement tree.

Summary

Functions

Prepares an element tree by pre-computing text measurements.

Re-prepares only elements whose content has changed.

Functions

prepare(element)

@spec prepare(map() | nil) :: Raxol.UI.Layout.PreparedElement.t() | nil

Prepares an element tree by pre-computing text measurements.

Returns a PreparedElement tree with cached measured_width and measured_height values for all text-bearing nodes.

prepare_incremental(element, old)

@spec prepare_incremental(map() | nil, Raxol.UI.Layout.PreparedElement.t() | nil) ::
  Raxol.UI.Layout.PreparedElement.t() | nil

Re-prepares only elements whose content has changed.

Compares content hashes between old and new trees. Returns a new PreparedElement tree reusing measurements from old_prepared where content hasn't changed.