Minga.Core.WidthOracle protocol (Minga v0.1.0)

Copy Markdown View Source

Measures display width for wrap computation.

The render pipeline passes an oracle value into Minga.Core.WrapMap so wrap decisions can stay BEAM-owned while the measurement strategy varies by frontend. The safe production oracle is monospace. Measured oracles are opt-in and only make sense when the caller owns the cache.

Summary

Types

t()

All the types that implement this protocol.

Functions

Returns the display width of a text string.

Returns a compact fingerprint that changes when wrapped text measurement changes.

Returns the display width of a single grapheme.

Types

t()

@type t() :: term()

All the types that implement this protocol.

Functions

display_width(oracle, text)

@spec display_width(t(), String.t()) :: non_neg_integer()

Returns the display width of a text string.

fingerprint(oracle)

@spec fingerprint(t()) :: term()

Returns a compact fingerprint that changes when wrapped text measurement changes.

grapheme_width(oracle, grapheme)

@spec grapheme_width(t(), String.t()) :: non_neg_integer()

Returns the display width of a single grapheme.