euporie.core.layout.scroll

Contains containers which display children at full height vertially stacked.

Functions

cast(typ, val)

Cast a value to a type.

get_app()

Get the current active (running) Application.

run_in_thread_with_context(func, *args[, daemon])

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

to_container(container)

Make sure that the given object is a Container.

to_dimension(value)

Turn the given object into a Dimension object.

Classes

BoundedWritePosition(xpos, ypos, width, height)

A write position which also hold bounding box information.

CachedContainer(content[, mouse_handler_wrapper])

A container which renders its content once and caches the output.

Container()

Base class for user interface layout.

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

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

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

Mouse event, sent to UIControl.mouse_handler.

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

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

PrintingContainer(children[, width, ...])

A container which displays all it's children in a vertical list.

ScrollOffsets([top, bottom, left, right])

Scroll offsets for the Window class.

ScrollingContainer(children[, height, ...])

A scrollable container which renders only the currently visible children.

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

Content generated by a user control.

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

Container that holds a control.

WindowRenderInfo(window, ui_content, ...)

Render information for the last render time of this control.

class euporie.core.layout.scroll.PrintingContainer(children: Callable | Sequence[AnyContainer], width: AnyDimension = None, key_bindings: KeyBindingsBase | None = None)

Bases: Container

A container which displays all it’s children in a vertical list.

property children: Sequence[AnyContainer]

Return the container’s children.

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

Return a list of all child containers.

get_key_bindings() KeyBindingsBase | None

Return the container’s key bindings.

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

Return the preferred height, equal to the sum of the child heights.

preferred_width(max_available_width: int) Dimension

Calculate and returns the desired width for this container.

reset() None

Reet the state of this container and all the children.

Does nothing as this container is used for dumping output.

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

Render the container to a Screen instance.

All children are rendered vertically in sequence.

Parameters:
class euporie.core.layout.scroll.ScrollingContainer(children: Callable[[], Sequence[AnyContainer]] | Sequence[AnyContainer], height: AnyDimension = None, width: AnyDimension = None, style: str | Callable[[], str] = '', scroll_offsets: ScrollOffsets | None = None)

Bases: Container

A scrollable container which renders only the currently visible children.

all_children() Sequence[Container]

Return the list of all children of this container.

get_child(index: int | None = None) CachedContainer

Return a rendered instance of the child at the given index.

If no index is given, the currently selected child is returned.

Parameters:

index – The index of the child to return.

Returns:

A rendered instance of the child.

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

Return the list of currently visible children to include in the layout.

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.

property known_sizes: dict[int, int]

A dictionary mapping child indices to height values.

mouse_scroll_handler(mouse_event: MouseEvent) NotImplementedOrNone

Mouse handler to scroll the pane.

pre_render_children(width: int, height: int) None

Render all unrendered children in a background thread.

preferred_height(width: int, max_available_height: int) Dimension

Return the preferred height only if one is provided.

preferred_width(max_available_width: int) Dimension

Do not provide a preferred width - grow to fill the available space.

reset() None

Reset the state of this container and all the children.

scroll(n: int) NotImplementedOrNone

Scroll up or down a number of rows.

Parameters:

n – The number of rows to scroll, negative for up, positive for down

Returns:

NotImplemented is scrolling is not allowed, otherwise

None

scroll_to(index: int, anchor: Literal['top', 'bottom'] | None = None) None

Scroll a child into view.

Parameters:
  • index – The child index to scroll into view

  • anchor – Whether to scroll to the top or bottom the given child index

select(index: int, extend: bool = False, position: int | None = None, scroll: bool = True) None

Select a child or adds it to the selection.

Parameters:
  • index – The index of the cell to select

  • extend – If true, the selection will be extended to include the cell

  • position – An optional cursor position index to apply to the cell input

  • scroll – Whether to scroll the page

property selected_indices: list[int]

Return in indices of the currently selected children.

property selected_slice: slice

Return the currently selected slice.

validate_slice(slice_: slice) slice

Ensure a slice describes a valid range of children.

property vertical_scroll: int

The best guess at the absolute vertical scroll position.

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

Write the actual content to the screen.

Children are rendered only if they are visible and have changed, and the output is cached to a separate screen object stored in a :py:ChildRenderInfo. The cached rendering of the children which are actually visible are then copied to the screen. This results in faster rendering of the scrolling container, and makes scrolling more performant.

Parameters: