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

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 every C0/C1 control byte, DEL, and ESC from text except \n and \t. The single trust boundary for control-byte stripping shared by every harness component that hands model-supplied text (tool args, approval referents, message bodies, ...) to Components.text() -- callers must route untrusted text through this rather than duplicating the pattern, so an embedded ESC/OSC sequence can never reach the terminal renderer disguised as real content.

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 every C0/C1 control byte, DEL, and ESC from text except \n and \t. The single trust boundary for control-byte stripping shared by every harness component that hands model-supplied text (tool args, approval referents, message bodies, ...) to Components.text() -- callers must route untrusted text through this rather than duplicating the pattern, so an embedded ESC/OSC sequence can never reach the terminal renderer disguised as real content.

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).