Skip to content

rs_rich.text

Generated from the type stubs by scripts/gen_python_api.py; do not edit.

rich.text: Text, Span and Lines.

Lines

append

append(line: Text) -> None

extend

extend(lines: Iterable[Text]) -> None

pop

pop(index: int = -1) -> Text

justify

justify(console: Console, width: int, justify: JustifyMethod = 'left', overflow: OverflowMethod = 'fold') -> None

Span

Bases: NamedTuple

start instance-attribute

start: int

end instance-attribute

end: int

style instance-attribute

style: Union[str, Style]

split

split(offset: int) -> Tuple[Span, Optional[Span]]

move

move(offset: int) -> Span

right_crop

right_crop(offset: int) -> Span

extend

extend(cells: int) -> Span

Text

plain instance-attribute

plain: str

spans instance-attribute

spans: List[Span]

style instance-attribute

style: Union[str, Style]

justify instance-attribute

justify: Optional[JustifyMethod]

overflow instance-attribute

overflow: Optional[OverflowMethod]

no_wrap instance-attribute

no_wrap: Optional[bool]

end instance-attribute

end: str

tab_size instance-attribute

tab_size: Optional[int]

cell_len property

cell_len: int

markup property

markup: str

from_markup classmethod

from_markup(text: str, *, style: Union[str, Style] = '', emoji: bool = True, emoji_variant: Optional[Literal['emoji', 'text']] = None, justify: Optional[JustifyMethod] = None, overflow: Optional[OverflowMethod] = None, end: str = '\n') -> Text

from_ansi classmethod

from_ansi(text: str, *, style: Union[str, Style] = '', justify: Optional[JustifyMethod] = None, overflow: Optional[OverflowMethod] = None, no_wrap: Optional[bool] = None, end: str = '\n', tab_size: Optional[int] = 8) -> Text

styled classmethod

styled(text: str, style: StyleType = '', *, justify: Optional[JustifyMethod] = None, overflow: Optional[OverflowMethod] = None) -> Text

assemble classmethod

assemble(*parts: Union[str, Text, Tuple[str, StyleType]], style: Union[str, Style] = '', justify: Optional[JustifyMethod] = None, overflow: Optional[OverflowMethod] = None, no_wrap: Optional[bool] = None, end: str = '\n', tab_size: int = 8, meta: Optional[Dict[str, Any]] = None) -> Text

blank_copy

blank_copy(plain: str = '') -> Text

copy

copy() -> Text

stylize

stylize(style: Union[str, Style], start: int = 0, end: Optional[int] = None) -> None

stylize_before

stylize_before(style: Union[str, Style], start: int = 0, end: Optional[int] = None) -> None

apply_meta

apply_meta(meta: Dict[str, Any], start: int = 0, end: Optional[int] = None) -> None

on

on(meta: Optional[Dict[str, Any]] = None, **handlers: Any) -> Text

remove_suffix

remove_suffix(suffix: str) -> None

right_crop

right_crop(amount: int = 1) -> None

get_style_at_offset

get_style_at_offset(console: Console, offset: int) -> Style

extend_style

extend_style(spaces: int) -> None

highlight_regex

highlight_regex(re_highlight: Any, style: Optional[Union[Callable[[str], Optional[StyleType]], StyleType]] = None, *, style_prefix: str = '') -> int

highlight_words

highlight_words(words: Iterable[str], style: Union[str, Style], *, case_sensitive: bool = True) -> int

rstrip

rstrip() -> None

rstrip_end

rstrip_end(size: int) -> None

set_length

set_length(new_length: int) -> None

render

render(console: Console, end: str = '') -> List[Segment]

join

join(lines: Iterable[Text]) -> Text

expand_tabs

expand_tabs(tab_size: Optional[int] = None) -> None

truncate

truncate(max_width: int, *, overflow: Optional[OverflowMethod] = None, pad: bool = False) -> None

pad

pad(count: int, character: str = ' ') -> None

pad_left

pad_left(count: int, character: str = ' ') -> None

pad_right

pad_right(count: int, character: str = ' ') -> None

align

align(align: AlignMethod, width: int, character: str = ' ') -> None

append

append(text: Union[Text, str], style: Optional[Union[str, Style]] = None) -> Text

append_text

append_text(text: Text) -> Text

append_tokens

append_tokens(tokens: Iterable[Tuple[str, Optional[StyleType]]]) -> Text

copy_styles

copy_styles(text: Text) -> None

split

split(separator: str = '\n', *, include_separator: bool = False, allow_blank: bool = False) -> Lines

divide

divide(offsets: Iterable[int]) -> Lines

wrap

wrap(console: Console, width: int, *, justify: Optional[JustifyMethod] = None, overflow: Optional[OverflowMethod] = None, tab_size: int = 8, no_wrap: Optional[bool] = None) -> Lines

fit

fit(width: int) -> Lines

detect_indentation

detect_indentation() -> int

with_indent_guides

with_indent_guides(indent_size: Optional[int] = None, *, character: str = '│', style: StyleType = 'dim green') -> Text