euporie.core.widgets.menu
Define an application menu.
Functions
|
Turn a list of (style_str, text) tuples into another list where each string is exactly one character. |
|
Concatenate all the text parts again. |
|
Return the character width of this text fragment list. |
|
Get the current active (running) Application. |
|
Return width of a string. |
|
Accept both booleans and Filters as input and turn it into a Filter. |
|
Convert the given value (which can be formatted text) into a list of text fragments. |
|
Turn any kind of formatted text back into plain text. |
Classes
|
A custom completions menu. |
A custom completions menu control. |
|
|
Turn any callable into a Filter. |
|
Wrapper around any other container that can change the visibility. |
Base class for user interface layout. |
|
|
Specified dimension (width/height) of a user control or window. |
|
Float for use in a |
|
Control that displays formatted text. |
|
Several layouts, one stacked above/under the other. ::. |
A container for a set of key bindings. |
|
|
A container to hold the menubar and main application body. |
|
A prompt-toolkit compatible menu item with more advanced capabilities. |
|
Mouse event, sent to UIControl.mouse_handler. |
|
|
|
|
alias of |
|
|
Scroll offsets for the |
|
Draw a shadow underneath/behind this container. |
|
Content generated by a user control. |
|
Several layouts, one stacked left/right of the other. ::. |
|
Container that holds a control. |
partial(func, *args, **keywords) - new function with partial application of the given arguments and keywords. |
- class euporie.core.widgets.menu.CompletionsMenu(max_height: int | None = 16, scroll_offset: int | Callable[[], int] = 1, extra_filter: FilterOrBool = True, z_index: int = 100000000)
Bases:
prompt_toolkit.layout.containers.ConditionalContainer
A custom completions menu.
- 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) → prompt_toolkit.layout.dimension.Dimension
Return a
Dimension
that represents the desired height for this container.
- preferred_width(max_available_width: int) → prompt_toolkit.layout.dimension.Dimension
Return a
Dimension
that represents the desired width for this container.
- reset() → None
Reset the state of this container and all the children. (E.g. reset scroll offsets, etc…)
- write_to_screen(screen: prompt_toolkit.layout.screen.Screen, mouse_handlers: prompt_toolkit.layout.mouse_handlers.MouseHandlers, write_position: prompt_toolkit.layout.screen.WritePosition, parent_style: str, erase_bg: bool, z_index: int | None) → None
Write the actual content to the screen.
- Parameters
screen –
Screen
mouse_handlers –
MouseHandlers
.parent_style – Style string to pass to the
Window
object. This will be applied to all content of the windows.VSplit
andHSplit
can use it to pass their style down to the windows that they contain.z_index – Used for propagating z_index from parent to child.
- class euporie.core.widgets.menu.CompletionsMenuControl
Bases:
prompt_toolkit.layout.menus.CompletionsMenuControl
A custom completions menu control.
- MIN_WIDTH = 7
- create_content(width: int, height: int) → prompt_toolkit.layout.controls.UIContent
Create a UIContent object for this control.
- get_invalidate_events() → Iterable[Event[object]]
Return a list of Event objects. This can be a generator. (The application collects all these events, in order to bind redraw handlers to these events.)
- get_key_bindings() → KeyBindingsBase | None
The key bindings that are specific for this user control.
Return a
KeyBindings
object if some key bindings are specified, or None otherwise.
- mouse_handler(mouse_event: MouseEvent) → NotImplementedOrNone
Handle mouse events: clicking and scrolling.
- move_cursor_down() → None
Request to move the cursor down. This happens when scrolling down and the cursor is completely at the top.
- class euporie.core.widgets.menu.MenuBar(app: BaseApp, menu_items: Sequence[MenuItem], grid: GridStyle = ▛▀▀▜ ▌ │▐ ▌─┼▐ ▙▄▄▟)
Bases:
object
A container to hold the menubar and main application body.
- class euporie.core.widgets.menu.MenuItem(formatted_text: AnyFormattedText = '', description: str = '', separator: bool = False, handler: Callable[[], None] | None = None, children: list[MenuItem] | None = None, shortcut: AnyFormattedText = '', hidden: FilterOrBool = False, disabled: FilterOrBool = False, toggled: Filter | None = None, collapse_prefix: bool = False, collapse_suffix: bool = True)
Bases:
object
A prompt-toolkit compatible menu item with more advanced capabilities.
It can use a function to generate formatted text to display, display a checkmark if a condition is true, and disable the handler if a condition is met.
- property formatted_text: StyleAndTextTuples
Generate the formatted text for this menu item.
- property prefix: StyleAndTextTuples
The item’s prefix.
Formatted text that will be displayed before the item’s main text. All prefixes in a menu are left aligned and padded to take up equal width.
- Returns
Formatted text
- property suffix: StyleAndTextTuples
The item’s suffix.
Formatted text that will be displayed aligned right after them item’s main text.
- Returns
Formatted text