euporie.core.margins

Contain margins.

Functions

cast(typ, val)

Cast a value to a type.

get_app()

Get the current active (running) Application.

to_filter(bool_or_filter)

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

Classes

ABCMeta(name, bases, namespace, /, **kwargs)

Metaclass for defining Abstract Base Classes (ABCs).

ClickableMargin()

A margin sub-class which handles mouse events.

Container()

Base class for user interface layout.

Dimension([min, max, weight, preferred])

Specified dimension (width/height) of a user control or window.

FormattedTextControl([text, style, ...])

Control that displays formatted text.

Margin()

Base interface for a margin.

MarginContainer(margin, target)

A container which renders a stand-alone margin.

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

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

Mouse event, which also store relative position of the mouse event in a cell.

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

NumberedDiffMargin()

Margin that displays the line numbers of a Window.

OverflowMargin()

A margin which indicates lines extending beyond the edge of the window.

Point(x, y)

PtkMouseEvent

alias of prompt_toolkit.mouse_events.MouseEvent

RelativePosition(x, y)

Store the relative position or the mouse within a terminal cell.

ScrollbarMargin([display_arrows, ...])

Margin displaying a scrollbar.

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

Container that holds a control.

class euporie.core.margins.ClickableMargin

Bases: prompt_toolkit.layout.margins.Margin

A margin sub-class which handles mouse events.

abstract create_margin(window_render_info: WindowRenderInfo, width: int, height: int) StyleAndTextTuples

Creates a margin. This should return a list of (style_str, text) tuples.

Parameters
  • window_render_infoWindowRenderInfo instance, generated after rendering and copying the visible part of the UIControl into the Window.

  • width – The width that’s available for this margin. (As reported by get_width().)

  • height – The height that’s available for this margin. (The height of the Window.)

abstract get_width(get_ui_content: Callable[[], prompt_toolkit.layout.controls.UIContent]) int

Return the width that this margin is going to consume.

Parameters

get_ui_content – Callable that asks the user control to create a UIContent instance. This can be used for instance to obtain the number of lines.

set_write_position(write_position: WritePosition) None

Set the write position of the menu.

write_position: WritePosition | None
class euporie.core.margins.MarginContainer(margin: Margin, target: ScrollableContainer)

Bases: prompt_toolkit.layout.containers.Window

A container which renders a stand-alone margin.

create_fragments() StyleAndTextTuples

Generate text fragments to display.

get_children() list[prompt_toolkit.layout.containers.Container]

Return the list of child Container objects.

get_key_bindings() KeyBindingsBase | None

Return a KeyBindings object.

is_modal() bool

When this container is modal.

preferred_height(width: int, max_available_height: int) prompt_toolkit.layout.dimension.Dimension

Return a thedesired height for this container.

preferred_width(max_available_width: int) prompt_toolkit.layout.dimension.Dimension

Return a the desired width for this container.

reset() None

Reet the state of this container and all the children.

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

Write the actual content to the screen.

class euporie.core.margins.NumberedDiffMargin

Bases: prompt_toolkit.layout.margins.Margin

Margin that displays the line numbers of a Window.

create_margin(window_render_info: WindowRenderInfo, width: int, height: int) StyleAndTextTuples

Generate the margin’s content.

get_width(get_ui_content: Callable[[], UIContent]) int

Return the width of the margin.

style = 'class:line-number'
class euporie.core.margins.OverflowMargin

Bases: prompt_toolkit.layout.margins.Margin

A margin which indicates lines extending beyond the edge of the window.

create_margin(window_render_info: WindowRenderInfo, width: int, height: int) StyleAndTextTuples

Generate the margin’s content.

get_width(get_ui_content: Callable[[], UIContent]) int

Return the width of the margin.

class euporie.core.margins.ScrollbarMargin(display_arrows: Union[prompt_toolkit.filters.base.Filter, bool] = True, up_arrow_symbol: str = '▴', down_arrow_symbol: str = '▾', autohide: Union[prompt_toolkit.filters.base.Filter, bool] = False, smooth: bool = True, style: str = '')

Bases: euporie.core.margins.ClickableMargin

Margin displaying a scrollbar.

Parameters
  • display_arrows – Display scroll up/down arrows.

  • up_arrow – Character to use for the scrollbar’s up arrow

  • down_arrow – Character to use for the scrollbar’s down arrow

  • smooth – Use block character to move scrollbar more smoothly

create_margin(window_render_info: WindowRenderInfo | None, width: int, height: int, margin_render_info: WindowRenderInfo | None = None) StyleAndTextTuples

Create the margin’s formatted text.

eighths = '█▇▆▅▄▃▂▁ '
get_width(get_ui_content: Callable[[], UIContent]) int

Return the scrollbar width: always 1.

mouse_handler(mouse_event: PtkMouseEvent) NotImplementedOrNone

Type compatible mouse handler.

async repeat(mouse_event: prompt_toolkit.mouse_events.MouseEvent, timeout: float = 0.1) None

Repeat a mouse event after a timeout.

set_write_position(write_position: WritePosition) None

Set the write position of the menu.

write_position: WritePosition | None