euporie.core.io

Define custom inputs and outputs, and related methods.

Functions

b64encode(s[, altchars])

Encode the bytes-like object s using Base64 and return a bytes object.

Classes

DummyInput()

Input for use in a DummyApplication

IgnoredInput()

An input which ignores input but does not immediately close the app.

PtkVt100_Output

alias of prompt_toolkit.output.vt100.Vt100_Output

Vt100Parser(*args, **kwargs)

A Vt100Parser which checks input against additional key patterns.

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

A Vt100 output which enables SGR pixel mouse positioning.

class euporie.core.io.IgnoredInput

Bases: prompt_toolkit.input.base.DummyInput

An input which ignores input but does not immediately close the app.

attach(input_ready_callback: Callable[[], None]) ContextManager[None]

Do not call the callback, so the input is never closed.

close() None

Close input.

property closed: bool

Should be true when the input stream is closed.

cooked_mode() ContextManager[None]

Context manager that turns the input into cooked mode.

detach() ContextManager[None]

Return a context manager that makes sure that this input is not active in the current event loop.

fileno() int

Fileno for putting this in an event loop.

flush() None

The event loop can call this when the input has to be flushed.

flush_keys() list[prompt_toolkit.key_binding.key_processor.KeyPress]

Flush the underlying parser. and return the pending keys. (Used for vt100 input.)

raw_mode() ContextManager[None]

Context manager that turns the input into raw mode.

read_keys() list[prompt_toolkit.key_binding.key_processor.KeyPress]

Return a list of Key objects which are read/parsed from the input.

typeahead_hash() str

Identifier for storing type ahead key presses.

class euporie.core.io.Vt100Parser(*args: Any, **kwargs: Any)

Bases: prompt_toolkit.input.vt100_parser.Vt100Parser

A Vt100Parser which checks input against additional key patterns.

feed(data: str) None

Feed the input stream.

Parameters

data – Input string (unicode).

feed_and_flush(data: str) None

Wrapper around feed and flush.

flush() None

Flush the buffer of the input stream.

This will allow us to handle the escape key (or maybe meta) sooner. The input received by the escape key is actually the same as the first characters of e.g. Arrow-Up, so without knowing what follows the escape sequence, we don’t know whether escape has been pressed, or whether it’s something else. This flush function should be called after a timeout, and processes everything that’s still in the buffer as-is, so without assuming any characters will follow.

reset(request: bool = False) None
class euporie.core.io.Vt100_Output(stdout: TextIO, get_size: Callable[[], prompt_toolkit.data_structures.Size], term: str | None = None, default_color_depth: prompt_toolkit.output.color_depth.ColorDepth | None = None, enable_bell: bool = True, enable_cpr: bool = True)

Bases: prompt_toolkit.output.vt100.Vt100_Output

A Vt100 output which enables SGR pixel mouse positioning.

ask_for_cpr() None

Asks for a cursor position report (CPR).

bell() None

Sound bell.

clear_title() None

Clear title again. (or restore previous title.)

cursor_backward(amount: int) None

Move cursor amount place backward.

cursor_down(amount: int) None

Move cursor amount place down.

cursor_forward(amount: int) None

Move cursor amount place forward.

cursor_goto(row: int = 0, column: int = 0) None

Move cursor position.

cursor_up(amount: int) None

Move cursor amount place up.

disable_autowrap() None

Disable auto line wrapping.

disable_bracketed_paste() None

For vt100 only.

disable_extended_keys() None

Disable extended keys.

disable_mouse_support() None

Additionally disable SGR-pixel mouse positioning.

enable_autowrap() None

Enable auto line wrapping.

enable_bracketed_paste() None

For vt100 only.

enable_extended_keys() None

Request extended keys.

enable_mouse_support() None

Additionally enable SGR-pixel mouse positioning.

encoding() str

Return encoding used for stdout.

enter_alternate_screen() None

Go to the alternate screen buffer. (For full screen applications).

erase_down() None

Erases the screen from the current line down to the bottom of the screen.

erase_end_of_line() None

Erases from the current cursor position to the end of the current line.

erase_screen() None

Erases the screen with the background colour and moves the cursor to home.

fileno() int

Return file descriptor.

flush() None

Write to output stream and flush.

classmethod from_pty(stdout: TextIO, term: str | None = None, default_color_depth: prompt_toolkit.output.color_depth.ColorDepth | None = None, enable_bell: bool = True) prompt_toolkit.output.vt100.Vt100_Output

Create an Output class from a pseudo terminal. (This will take the dimensions by reading the pseudo terminal attributes.)

get_clipboard() None

Get clipboard contents using OSC-52.

get_default_color_depth() prompt_toolkit.output.color_depth.ColorDepth

Return the default color depth for a vt100 terminal, according to the our term value.

We prefer 256 colors almost always, because this is what most terminals support these days, and is a good default.

get_rows_below_cursor_position() int

For Windows only.

get_size() prompt_toolkit.data_structures.Size

Return the size of the output window.

hide_cursor() None

Hide cursor.

quit_alternate_screen() None

Leave the alternate screen buffer.

reset_attributes() None

Reset color and styling attributes.

reset_cursor_key_mode() None

For vt100 only. Put the terminal in cursor mode (instead of application mode).

reset_cursor_shape() None

Reset cursor shape.

property responds_to_cpr: bool

True if the Application can expect to receive a CPR response after calling ask_for_cpr (this will come back through the corresponding Input).

This is used to determine the amount of available rows we have below the cursor position. In the first place, we have this so that the drop down autocompletion menus are sized according to the available space.

On Windows, we don’t need this, there we have get_rows_below_cursor_position.

scroll_buffer_to_prompt() None

For Win32 only.

set_attributes(attrs: prompt_toolkit.styles.base.Attrs, color_depth: prompt_toolkit.output.color_depth.ColorDepth) None

Create new style and output.

Parameters

attrsAttrs instance.

set_clipboard(text: str) None

Set clipboard data using OSC-52.

set_cursor_shape(cursor_shape: prompt_toolkit.cursor_shapes.CursorShape) None

Set cursor shape to block, beam or underline.

set_title(title: str) None

Set terminal title.

show_cursor() None

Show cursor.

stdout: TextIO = None
write(data: str) None

Write text to output. (Removes vt100 escape codes. – used for safely writing text.)

write_raw(data: str) None

Write raw data to output.