mirror of
https://github.com/1j01/textual-paint.git
synced 2024-12-23 06:41:32 +03:00
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
"""
|
|
This type stub file was generated by pyright.
|
|
"""
|
|
|
|
from typing import Iterable, Iterator, Text
|
|
from ._misc import _CustomText
|
|
from .instruction import Instruction
|
|
from .token import Token
|
|
|
|
"""A dedicated class for representing ANSI escape sequences."""
|
|
def isescape(text: Text) -> bool:
|
|
"""Return True if text is an ANSI escape sequence."""
|
|
...
|
|
|
|
class Escape(_CustomText):
|
|
"""A single ANSI escape sequence."""
|
|
SEPARATOR = ...
|
|
ALL_ATTRIBUTE_CODES: set[int] = ...
|
|
ALL_FOREGROUND_CODES: set[int] = ...
|
|
ALL_BACKGROUND_CODES: set[int] = ...
|
|
ALL_COLOR_CODES: set[int] = ...
|
|
def tokens(self) -> Iterator[Token]:
|
|
"""Yield individual tokens from the escape sequence."""
|
|
...
|
|
|
|
def instructions(self) -> Iterable[Instruction]:
|
|
r"""
|
|
Decode a string of tokens into escapable objects.
|
|
|
|
Examples
|
|
--------
|
|
>>> list(Escape("\x1b[1m").instructions())
|
|
[SetAttribute(attribute=<Attribute.BOLD: 1>)]
|
|
>>> list(Escape("\x1b[5;44m")
|
|
... .instructions()) # doctest: +NORMALIZE_WHITESPACE
|
|
[SetAttribute(attribute=<Attribute.BLINK: 5>),
|
|
SetColor(role=<ColorRole.BACKGROUND: 40>, color=Ansi256(code=4))]
|
|
"""
|
|
...
|
|
|
|
|
|
|