textual.strip
This module contains the Strip
class and related objects.
A Strip
contains the result of rendering a widget.
See Line API for how to use Strips.
Strip
¶
Strip(segments, cell_length=None)
Represents a 'strip' (horizontal line) of a Textual Widget.
A Strip is like an immutable list of Segments. The immutability allows for effective caching.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Iterable[Segment]
|
An iterable of segments. |
required |
|
int | None
|
The cell length if known, or None to calculate on demand. |
None
|
adjust_cell_length
¶
adjust_cell_length(cell_length, style=None)
align
classmethod
¶
Align a list of strips on both axis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[Strip]
|
A list of strips, such as from a render. |
required |
|
Style
|
The Rich style of additional space. |
required |
|
int
|
Width of container. |
required |
|
int
|
Height of container. |
required |
|
AlignHorizontal
|
Horizontal alignment method. |
required |
|
AlignVertical
|
Vertical alignment method. |
required |
Returns:
Type | Description |
---|---|
Iterable[Strip]
|
An iterable of strips, with additional padding. |
apply_filter
¶
apply_filter(filter, background)
Apply a filter to all segments in the strip.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
LineFilter
|
A line filter object. |
required |
Returns:
Type | Description |
---|---|
Strip
|
A new Strip. |
blank
classmethod
¶
blank(cell_length, style=None)
crop
¶
crop_extend
¶
crop_pad
¶
crop_pad(cell_length, left, right, style)
Crop the strip to cell_length
, and add optional padding.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
int
|
Cell length of strip prior to padding. |
required |
|
int
|
Additional padding on the left. |
required |
|
int
|
Additional padding on the right. |
required |
|
Style
|
Style of any padding. |
required |
Returns:
Type | Description |
---|---|
Strip
|
Cropped and padded strip. |
extend_cell_length
¶
extend_cell_length(cell_length, style=None)
from_lines
classmethod
¶
from_lines(lines, cell_length=None)
Convert lines (lists of segments) to a list of Strips.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[list[Segment]]
|
List of lines, where a line is a list of segments. |
required |
|
int | None
|
Cell length of lines (must be same) or None if not known. |
None
|
Returns:
Type | Description |
---|---|
list[Strip]
|
List of strips. |
index_to_cell_position
¶
index_to_cell_position(index)
Given a character index, return the cell position of that character.
This is the sum of the cell lengths of all the characters before the character
at index
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
int
|
The index to convert. |
required |
Returns:
Type | Description |
---|---|
int
|
The cell position of the character at |
simplify
¶
StripRenderable
¶
A renderable which renders a list of strips in to lines.