Raxol.UI.Components.Harness.TextUtil (Raxol v2.9.2)

View Source

Display-width-aware text truncation and control-byte sanitization shared by harness components that ultimately hand model-supplied text to Components.text().

Summary

Functions

Strips C0/C1 controls and DEL from binary component text, retaining \n, \t, and the historical \r behavior encoded by the pattern. This is component-level normalization, not the terminal trust boundary; see Raxol.Core.Boundary.TermText's "Where confinement happens".

Truncates text to width display columns, appending a single-cell ellipsis when it overflows. Unlike Raxol.UI.TextLayout.truncate/3, a non-positive or non-integer width returns text unchanged (callers rely on this pass-through).

Functions

sanitize_controls(text)

@spec sanitize_controls(String.t()) :: String.t()

Strips C0/C1 controls and DEL from binary component text, retaining \n, \t, and the historical \r behavior encoded by the pattern. This is component-level normalization, not the terminal trust boundary; see Raxol.Core.Boundary.TermText's "Where confinement happens".

truncate_to_width(text, width)

@spec truncate_to_width(String.t(), integer()) :: String.t()

Truncates text to width display columns, appending a single-cell ellipsis when it overflows. Unlike Raxol.UI.TextLayout.truncate/3, a non-positive or non-integer width returns text unchanged (callers rely on this pass-through).