euporie.core.commands

Define a command object for use in key-bindings, menus, and the command palette.

Functions

add_cmd(**kwargs)

Add a command to the centralized command system.

cast(typ, val)

Cast a value to a type.

get_app()

Get the current active (running) Application.

get_cmd(name)

Get a command from the centralized command system by name.

isawaitable(object)

Return true if object can be passed to an await expression.

iscoroutinefunction(obj)

Return true if the object is a coroutine function.

parse_keys(keys)

Pare a list of keys.

signature(obj, *[, follow_wrapped, globals, ...])

Get a signature object for the passed callable.

to_filter(bool_or_filter)

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

Classes

Binding(keys, ...], handler, filter, eager, ...)

Key binding: (key sequence + handler + filter).

Command(handler, *, filter, hidden, name, ...)

Wrap a function so it can be used as a key-binding or a menu item.

KeyPressEvent(key_processor_ref, arg, ...)

Key press event, delivered to key bindings.

Keys(value[, names, module, qualname, type, ...])

List of keys for use in key bindings.

class euporie.core.commands.Command(handler: CommandHandler, *, filter: FilterOrBool = True, hidden: FilterOrBool = False, name: str | None = None, title: str | None = None, menu_title: str | None = None, description: str | None = None, toggled: Filter | None = None, eager: FilterOrBool = False, is_global: FilterOrBool = False, save_before: Callable[[KeyPressEvent], bool] = <function Command.<lambda>>, record_in_macro: FilterOrBool = True)

Bases: object

Wrap a function so it can be used as a key-binding or a menu item.

bind(key_bindings: KeyBindingsBase, keys: AnyKeys) None

Add the current commands to a set of key bindings.

Parameters
  • key_bindings – The set of key bindings to bind to

  • keys – Additional keys to bind to the command

property key_handler: KeyHandlerCallable

Return a key handler for the command.

key_str() str

Return a string representing the first registered key-binding.

property menu: MenuItem

Return a menu item for the command.

property menu_handler: Callable[[], None]

Return a menu handler for the command.

run() None

Run the command’s handler.

euporie.core.commands.add_cmd(**kwargs: Any) Callable

Add a command to the centralized command system.

euporie.core.commands.get_cmd(name: str) euporie.core.commands.Command

Get a command from the centralized command system by name.

Parameters

name – The name of the command to retrieve

Returns

The requested command object

Raises

KeyError – Raised if the named command is not found