Skip to main content

Module text

Module text 

Source
Expand description

Styled text utilities.

This module provides a small, generic representation of “styled spans” and helper functions for measuring and manipulating them in terms of terminal cell width.

Structs§

Span
A segment of text with a single style.
WrapOpts
Options controlling span-aware word wrapping.

Functions§

apply_highlight
Apply highlighting to spans using grapheme-index ranges.
clip_to_cells_spans
Clip spans to at most w cells.
clip_to_cells_text
Clip a plain string to at most w cells.
ellipsis_to_cells_spans
Ellipsize spans to at most w cells using the provided ellipsis_span.
ellipsis_to_cells_text
Ellipsize a plain string to at most w cells using the provided ellipsis.
measure_cells_spans
Measure spans in terminal cells using the provided glyph registry.
measure_cells_text
Measure a plain string in terminal cells using the provided glyph registry.
normalize_spans
Normalize spans by:
spans_plain_text
Returns the concatenated plain-text content of spans.
wrap_spans_wordwise
Wrap spans word-wise into a sequence of visual lines.

Type Aliases§

Spans
A convenience alias for a sequence of styled spans.