rich.segment¶
- class rich.segment.ControlType(value, names=None, *values, module=None, qualname=None, type=None, start=1, boundary=None)[源代码]¶
不可打印的控制代码,通常转换为ANSI代码。
- class rich.segment.Segment(text, style=None, control=None)[源代码]¶
具有关联样式的一段文本。段由控制台呈现过程产生,并最终被转换成要写入终端的字符串。
- 参数
- cell_length¶
此段的单元格长度。
- 类型
集成
- classmethod align_bottom(lines, width, height, style, new_lines=False)[源代码]¶
将渲染与底部对齐(根据需要在上方添加额外的行)。
- 参数:
行(列表 [List[Segment] ]):行的列表。Width(Int):所需宽度。Height(int,可选):所需高度或无以保持不变。Style(Style):添加的任何填充的样式。默认为无。New_line(bool,可选):填充的行应包括“
“。默认为FALSE。
- 返回:
明细表 [List[Segment] ]:新的行列表。
- classmethod align_middle(lines, width, height, style, new_lines=False)[源代码]¶
将线条居中对齐(根据需要在上方和下方添加额外的线条)。
- 参数:
行(列表 [List[Segment] ]):行的列表。Width(Int):所需宽度。Height(int,可选):所需高度或无以保持不变。Style(Style):添加的任何填充的样式。New_line(bool,可选):填充的行应包括“
“。默认为FALSE。
- 返回:
明细表 [List[Segment] ]:新的行列表。
- classmethod align_top(lines, width, height, style, new_lines=False)[源代码]¶
将线条与顶部对齐(根据需要向底部添加额外线条)。
- 参数:
行(列表 [List[Segment] ]):行的列表。Width(Int):所需宽度。Height(int,可选):所需高度或无以保持不变。Style(Style):添加的任何填充的样式。New_line(bool,可选):填充的行应包括“
“。默认为FALSE。
- 返回:
明细表 [List[Segment] ]:新的行列表。
- classmethod apply_style(segments, style=None, post_style=None)[源代码]¶
将样式(S)应用于段的可迭代。
返回将样式替换为的段的可迭代数
style + segment.style + post_style
。
- control: Optional[Sequence[Union[Tuple[ControlType], Tuple[ControlType, Union[int, str]], Tuple[ControlType, int, int]]]]¶
字段号2的别名
- classmethod set_shape(lines, width, height=None, style=None, new_lines=False)[源代码]¶
设置线条列表(包围矩形)的形状。
- 参数:
行(列表 [List[Segment] ]):行的列表。Width(Int):所需宽度。Height(int,可选):所需高度或无以保持不变。Style(style,可选):添加的任何填充的样式。New_line(bool,可选):填充的行应包括“
“。默认为FALSE。
- 返回:
明细表 [List[Segment] ]:新的行列表。
- classmethod split_and_crop_lines(segments, length, style=None, pad=True, include_new_lines=True)[源代码]¶
将线段拆分为多条线,并裁剪大于给定长度的线。