euporie.core.renderer

Extended version of prompt_toolkit’s renderer.

Functions

to_filter(bool_or_filter)

Accept both booleans and Filters as input and turn it into a Filter.

Classes

BoundedWritePosition(xpos, ypos, width, height)

A write position which also hold bounding box information.

MouseHandlers()

Two dimensional raster of callbacks for mouse events.

Point(x, y)

PtkRenderer

alias of Renderer

Renderer(style, output[, full_screen, ...])

Renderer with modifications.

Screen([default_char, initial_width, ...])

Screen class which uses :py:`BoundedWritePosition`s.

Size(rows, columns)

Vt100_Output(stdout, get_size[, term, ...])

A Vt100 output which enables SGR pixel mouse positioning.

class euporie.core.renderer.Renderer(style: BaseStyle, output: Output, full_screen: bool = False, mouse_support: FilterOrBool = False, cpr_not_supported_callback: Callable[[], None] | None = None, extend_height: FilterOrBool = False, extend_width: FilterOrBool = False)

Bases: Renderer

Renderer with modifications.

CPR_TIMEOUT = 2
clear() None

Clear screen and go to 0,0

erase(leave_alternate_screen: bool = True) None

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.)

Parameters:

leave_alternate_screen – When True, and when inside an alternate screen buffer, quit the alternate screen.

property height_is_known: bool

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.)

property last_rendered_screen: prompt_toolkit.layout.screen.Screen | None

The Screen class that was generated during the last rendering. This can be None.

render(app: Application[Any], layout: Layout, is_done: bool = False) None

Render the current interface to the output.

report_absolute_cursor_row(row: int) None

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

request_absolute_cursor_position() None

Get current cursor position.

We do this to calculate the minimum available height that we can consume for rendering the prompt. This is the available space below te cursor.

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

reset(_scroll: bool = False, leave_alternate_screen: bool = True) None

Reset the output.

property rows_above_layout: int

Return the number of rows visible in the terminal above the layout.

async wait_for_cpr_responses(timeout: int = 1) None

Wait for a CPR response.

property waiting_for_cpr: bool

Waiting for CPR flag. True when we send the request, but didn’t got a response.