Expand description
Segment — styled text unit. Equivalent to Rich’s segment.py.
A Segment is the smallest unit of output: a piece of text with an
associated style and optional control codes.
Structs§
- Segment
- A piece of text with an associated style.
- Segments
- A collection of
Segments, with convenience methods.
Enums§
- Control
Code - Control
Type - Non-printable control codes (equivalent to Rich’s
ControlType).
Functions§
- align_
bottom - Align lines to the bottom of a region of given height.
- align_
middle - Align lines to the middle of a region of given height.
- align_
top - Align lines to the top of a region of given height.
- divide
- Divide segments at the given cell offsets.
- filter_
control - Filter segments, keeping only control codes if
is_controlis true, or only non-control segments ifis_controlis false. - get_
line_ length - Get the total cell length of a line of segments.
- line
- Helper: create a newline segment.
- set_
shape - Set segments to an exact width and height, padding/truncating as needed.
- space
- Helper: create a space segment.
- split_
lines - Split an iterable of segments into lines at newline boundaries.
- strip_
links - Remove link IDs and URLs from all segment styles.
- strip_
styles - Remove all styles from segments, returning plain text only.