← Back
Editing: key_bindings.cpython-311.pyc
� �Ïc�Q � � � d Z ddlmZmZmZ ddlmZ ddlmZm Z m Z mZmZm Z mZmZmZmZmZ ddlmZ ddlmZmZmZ ddlmZmZ erdd lmZ eZg d �Z e dgede d f f Z! G d � d� � Z"eeee#f df Z$ G d� de�� � Z% edee!e"f �� � Z& G d� de%� � Z'deee#f dee#ef fd�Z(dddd� dfdededed e dge)f d!ede e!ge"f fd"�Z* G d#� d$e%� � Z+ G d%� d&e+� � Z, G d'� d(e+� � Z-d)ee% de-fd*�Z. G d+� d,e+� � Z/ G d-� d.e+� � Z0d/S )0aF Key bindings registry. A `KeyBindings` object is a container that holds a list of key bindings. It has a very efficient internal data structure for checking which key bindings apply for a pressed key. Typical usage:: kb = KeyBindings() @kb.add(Keys.ControlX, Keys.ControlC, filter=INSERT) def handler(event): # Handle ControlX-ControlC key sequence. pass It is also possible to combine multiple KeyBindings objects. We do this in the default key bindings. There are some KeyBindings objects that contain the Emacs bindings, while others contain the Vi bindings. They are merged together using `merge_key_bindings`. We also have a `ConditionalKeyBindings` object that can enable/disable a group of key bindings at once. It is also possible to add a filter to a function, before a key binding has been assigned, through the `key_binding` decorator.:: # First define a key handler with the `filter`. @key_binding(filter=condition) def my_key_binding(event): ... # Later, add it to the key bindings. kb.add(Keys.A, my_key_binding) � )�ABCMeta�abstractmethod�abstractproperty)�isawaitable)� TYPE_CHECKING� Awaitable�Callable�Hashable�List�Optional�Sequence�Tuple�TypeVar�Union�cast)�SimpleCache)�FilterOrBool�Never� to_filter)�KEY_ALIASES�Keys� )� KeyPressEvent)�NotImplementedOrNone�Binding�KeyBindingsBase�KeyBindings�ConditionalKeyBindings�merge_key_bindings�DynamicKeyBindings�GlobalOnlyKeyBindingsr r c � � e Zd ZdZdddd� dfdeeeef df dede d e d e de dgef d e ddfd�Zdd�Z defd�ZdS )r z� Key binding: (key sequence + handler + filter). (Immutable binding class.) :param record_in_macro: When True, don't record this key binding when a macro is recorded. TFc � � dS �NT� ��es �I/usr/lib/python3/dist-packages/prompt_toolkit/key_binding/key_bindings.py�<lambda>zBinding.<lambda>p � � �D� � �keys.�handler�filter�eager� is_global�save_beforer �record_in_macro�returnNc �� � || _ || _ t |� � | _ t |� � | _ t |� � | _ || _ t |� � | _ d S �N)r, r- r r. r/ r0 r1 r2 )�selfr, r- r. r/ r0 r1 r2 s r( �__init__zBinding.__init__i s] � � �� ������'�'����u�%�%�� �"�9�-�-���&���(��9�9����r+ �eventc �* ��� | � �� � }t |� � rFt t d |� � �d��fd�}�j � |� � � � d S |t k r�j � � � d S d S )Nr r3 c � �h �K � �� d {V ��} | t k r�j � � � d S d S r5 )�NotImplemented�app� invalidate)�result� awaitabler8 s ��r( �bg_taskzBinding.call.<locals>.bg_task� sE �� � � �(���������^�+�+��I�(�(�*�*�*�*�*� ,�+r+ �r3 N)r- r r r r<