Reference

Inputstream

Inputstream handler

Line

Code

Prompt

Renderer

Renders the command line on the console. (Redraws parts of the input line that were changed.)

class prompt_toolkit.renderer.Renderer(output, use_alternate_screen=False)

Typical usage:

output = Vt100_Output.from_pty(sys.stdout)
r = Renderer(output)
r.render(cli, layout=..., style=...)
clear()

Clear screen and go to 0,0

erase()

Hide all output and put the cursor back at the first line. This is for instance used for running a system command (while hiding the CLI) and later resuming the same CLI.)

height_is_known

True when the height from the cursor until the bottom of the terminal is known. (It’s often nicer to draw bottom toolbars only if the height is known, in order to avoid flickering when the CPR response arrives.)

render(cli, layout, style=None, is_done=False)

Render the current interface to the output.

Parameters:is_done – When True, put the cursor at the end of the interface. We won’t print any changes to this part.
report_absolute_cursor_row(row)

To be called when we know the absolute cursor position. (As an answer of a “Cursor Position Request” response.)

request_absolute_cursor_position()

Get current cursor position. For vt100: Do CPR request. (answer will arrive later.) For win32: Do API call. (Answer comes immediately.)

prompt_toolkit.renderer.print_tokens(output, tokens, style)

Print a list of (Token, text) tuples in the given style to the output.