Skip to content

Draft: Supports colors in __info__

Valentin Valls requested to merge color-in-info into master

Feedback from @berruyer

Colors was not supported by the __info__ of the object.

This PR allow to return prompt toolkit formats like ANSI, HTML or FormattedText, as result we know some formatting have to by applied.

Tested with

class Foo:
    def __init__(self, something):
        self._something = something
    def __info__(self):
        return self._something

from prompt_toolkit import HTML
from bliss.common.utils import RED
from prompt_toolkit import ANSI
from prompt_toolkit.formatted_text import FormattedText


Foo("Coucou")

Foo(HTML("Cou<red>cou</red>"))

Foo(ANSI("Cou" + RED("cou")))

Foo(FormattedText([("", "Cou"), ("fg:red", "cou")]))

image

Merge request reports