euporie.core.widgets.display

Define custom controls which re-render on resize.

Functions

add_cmd(**kwargs)

Add a command to the centralized command system.

cast(typ, val)

Cast a value to a type.

ceil(x, /)

Return the ceiling of x as an Integral.

fragment_list_width(fragments)

Return the character width of this text fragment list.

get_app()

Get the current active (running) Application.

load_registered_bindings(*names[, config])

Assign key-bindings to commands based on a dictionary.

register_bindings(bindings)

Update the key-binding registry.

run_in_thread_with_context(func, *args[, daemon])

Run a function in an thread, but make sure it uses the same contextvars.

scrollable(window)

Return a filter which indicates if a window is scrollable.

split_lines(fragments)

Take a single list of (style_str, text) tuples and yield one such list for each line.

to_filter(bool_or_filter)

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

to_str(value)

Turn callable or string into string.

wrap(ft, width[, style, placeholder, left, ...])

Wrap formatted text at a given width.

Classes

ConditionalContainer(content, filter)

Wrapper around any other container that can change the visibility.

Datum(data, *args, **kwargs)

Class for storing and converting display data.

Display(datum[, height, width, focusable, ...])

Rich output displays.

DisplayControl(datum[, focusable, ...])

Web view displays.

DisplayWindow([content, width, height, ...])

A window sub-class which can scroll left and right.

Event(sender[, handler])

Simple event to which event handlers can be attached. For instance::.

FastDictCache(get_value[, size])

Fast, lightweight cache which keeps at most size items.

GraphicProcessor(control)

Class which loads and positions graphics references in a UIContent.

MarginContainer(margin, target)

A container which renders a stand-alone margin.

MouseEvent(position, event_type, button, ...)

Mouse event, sent to UIControl.mouse_handler.

MouseEventType(value[, names, module, ...])

Point(x, y)

ScrollbarMargin([display_arrows, ...])

Margin displaying a scrollbar.

SimpleCache([maxsize])

Very simple cache that discards the oldest item when the cache size is exceeded.

Size(rows, columns)

UIContent(get_line, StyleAndTextTuples] = >, ...)

Content generated by a user control.

UIControl()

Base class for all user interface controls.

VSplit(children[, window_too_small, align, ...])

Several layouts, one stacked left/right of the other.

Window([content, width, height, z_index, ...])

Container that holds a control.

partial

partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords.

class euporie.core.widgets.display.Display(datum: Datum, height: AnyDimension = None, width: AnyDimension = None, focusable: FilterOrBool = False, focus_on_click: FilterOrBool = False, wrap_lines: FilterOrBool = False, always_hide_cursor: FilterOrBool = True, scrollbar: FilterOrBool = True, scrollbar_autohide: FilterOrBool = True, dont_extend_height: FilterOrBool = True, dont_extend_width: FilterOrBool = False, style: str | Callable[[], str] = '')

Bases: object

Rich output displays.

A container for displaying rich output data.

property datum: Any

Return the display’s current data.

style() str

Use the background color of the data as the default style.

class euporie.core.widgets.display.DisplayControl(datum: Datum, focusable: FilterOrBool = False, focus_on_click: FilterOrBool = False, wrap_lines: FilterOrBool = False, dont_extend_width: FilterOrBool = False, threaded: bool = False)

Bases: UIControl

Web view displays.

A control which displays rendered HTML content.

property content_width: int

Return the width of the content.

create_content(width: int, height: int) UIContent

Generate the content for this user control.

Returns:

A UIContent instance.

property cursor_position: Point

Get the cursor position.

property datum: Any

Return the control’s display data.

get_content(datum: Datum, width: int, height: int, loading: bool, cursor_position: Point, color_palette: ColorPalette) UIContent

Create a cacheable UIContent.

get_invalidate_events() Iterable[Event[object]]

Return the Window invalidate events.

get_key_bindings() KeyBindingsBase | None

Return key bindings that are specific for this user control.

Returns:

A KeyBindings object if some key bindings are specified, or

None otherwise.

get_lines(datum: Datum, width: int | None, height: int | None, fg: str, bg: str, wrap_lines: bool = False) list[StyleAndTextTuples]

Render the lines to display in the control.

get_max_line_width(datum: Datum, width: int | None, height: int | None, wrap_lines: bool = False) int

Get the maximum lines width for a given rendering.

is_focusable() bool

Tell whether this user control is focusable.

mouse_handler(mouse_event: MouseEvent) NotImplementedOrNone

Mouse handler for this control.

move_cursor_down() None

Move the cursor down one line.

move_cursor_left() None

Move the cursor down one line.

move_cursor_right() None

Move the cursor up one line.

move_cursor_up() None

Move the cursor up one line.

preferred_height(width: int, max_available_height: int, wrap_lines: bool, get_line_prefix: GetLinePrefixCallable | None) int | None

Calculate and return the preferred height of the control.

preferred_width(max_available_width: int) int | None

Calculate and return the preferred width of the control.

render() None

Render the HTML DOM in a thread.

reset() None

Reset the state of the control.

class euporie.core.widgets.display.DisplayWindow(content: UIControl | None = None, width: AnyDimension = None, height: AnyDimension = None, z_index: int | None = None, dont_extend_width: FilterOrBool = False, dont_extend_height: FilterOrBool = False, ignore_content_width: FilterOrBool = False, ignore_content_height: FilterOrBool = False, left_margins: Sequence[Margin] | None = None, right_margins: Sequence[Margin] | None = None, scroll_offsets: ScrollOffsets | None = None, allow_scroll_beyond_bottom: FilterOrBool = False, wrap_lines: FilterOrBool = False, get_vertical_scroll: Callable[[Window], int] | None = None, get_horizontal_scroll: Callable[[Window], int] | None = None, always_hide_cursor: FilterOrBool = False, cursorline: FilterOrBool = False, cursorcolumn: FilterOrBool = False, colorcolumns: None | list[ColorColumn] | Callable[[], list[ColorColumn]] = None, align: WindowAlign | Callable[[], WindowAlign] = WindowAlign.LEFT, style: str | Callable[[], str] = '', char: None | str | Callable[[], str] = None, get_line_prefix: GetLinePrefixCallable | None = None)

Bases: Window

A window sub-class which can scroll left and right.

content: DisplayControl
get_children() list[prompt_toolkit.layout.containers.Container]

Return the list of child Container objects.

get_key_bindings() prompt_toolkit.key_binding.key_bindings.KeyBindingsBase | None

Returns a KeyBindings object. These bindings become active when any user control in this container has the focus, except if any containers between this container and the focused user control is modal.

is_modal() bool

When this container is modal, key bindings from parent containers are not taken into account if a user control in this container is focused.

preferred_height(width: int, max_available_height: int) Dimension

Calculate the preferred height for this window.

preferred_width(max_available_width: int) Dimension

Calculate the preferred width for this window.

reset() None

Reset the state of this container and all the children. (E.g. reset scroll offsets, etc…)

vertical_scroll: int
write_to_screen(screen: Screen, mouse_handlers: MouseHandlers, write_position: WritePosition, parent_style: str, erase_bg: bool, z_index: int | None) None

Write window to screen.