Skip to main content

Module segment

Module segment 

Source
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§

ControlCode
ControlType
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_control is true, or only non-control segments if is_control is 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.