fancy_repr
The __fancy_repl__ protocol.
SupportsFancyRepr
Bases: Protocol
An object that supports the __fancy_repr__ dunder.
Source code in pytermgui/fancy_repr.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
__fancy_repr__()
Yields some fancy text.
Each value yielded can be one of two types. If a dictionary is yielded,
it will be assumed to have text and highlight fields. text will be
the string included in the repr, and highlight will be a boolean describing
whether the part should be highlighted. At the moment highlighting is done by
highlight_python, but this might be configurable once more highlighters are
available.
If a str is yielded, it is assumed to be a shorthand for:
{"text": <your_text>, "highlight": True}
Source code in pytermgui/fancy_repr.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | |
build_fancy_repr(obj)
Interprets objects with the __fancy_repr__ protocol.
Source code in pytermgui/fancy_repr.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
supports_fancy_repr(obj)
Determines whether the given object supports the fancy repl protocol.
Source code in pytermgui/fancy_repr.py
37 38 39 40 | |