euporie.core.log.print_formatted_text

euporie.core.log.print_formatted_text(*values: Any, sep: str = ' ', end: str = '\n', file: TextIO | None = None, flush: bool = False, style: prompt_toolkit.styles.base.BaseStyle | None = None, output: prompt_toolkit.output.base.Output | None = None, color_depth: prompt_toolkit.output.color_depth.ColorDepth | None = None, style_transformation: prompt_toolkit.styles.style_transformation.StyleTransformation | None = None, include_default_pygments_style: bool = True) None
print_formatted_text(*values, sep=' ', end='\n', file=None, flush=False, style=None, output=None)

Print text to stdout. This is supposed to be compatible with Python’s print function, but supports printing of formatted text. You can pass a FormattedText, HTML or ANSI object to print formatted text.

  • Print HTML as follows:

    print_formatted_text(HTML('<i>Some italic text</i> <ansired>This is red!</ansired>'))
    
    style = Style.from_dict({
        'hello': '#ff0066',
        'world': '#884444 italic',
    })
    print_formatted_text(HTML('<hello>Hello</hello> <world>world</world>!'), style=style)
    
  • Print a list of (style_str, text) tuples in the given style to the output. E.g.:

    style = Style.from_dict({
        'hello': '#ff0066',
        'world': '#884444 italic',
    })
    fragments = FormattedText([
        ('class:hello', 'Hello'),
        ('class:world', 'World'),
    ])
    print_formatted_text(fragments, style=style)
    

If you want to print a list of Pygments tokens, wrap it in PygmentsTokens to do the conversion.

If a prompt_toolkit Application is currently running, this will always print above the application or prompt (similar to patch_stdout). So, print_formatted_text will erase the current application, print the text, and render the application again.

Parameters:
  • values – Any kind of printable object, or formatted string.

  • sep – String inserted between values, default a space.

  • end – String appended after the last value, default a newline.

  • styleStyle instance for the color scheme.

  • include_default_pygments_stylebool. Include the default Pygments style when set to True (the default).