← Back
Editing: auto_suggest.cpython-311.pyc
� �Ïc" � �6 � d Z ddlmZmZ ddlmZmZmZmZ ddl m Z ddlmZ ddl mZmZ erddlmZ g d �Z G d � d� � Z G d� d e�� � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � ZdS )a) `Fish-style <http://fishshell.com/>`_ like auto-suggestion. While a user types input in a certain buffer, suggestions are generated (asynchronously.) Usually, they are displayed after the input. When the cursor presses the right arrow and the cursor is at the end of the input, the suggestion will be inserted. If you want the auto suggestions to be asynchronous (in a background thread), because they take too much time, and could potentially block the event loop, then wrap the :class:`.AutoSuggest` instance into a :class:`.ThreadedAutoSuggest`. � )�ABCMeta�abstractmethod)� TYPE_CHECKING�Callable�Optional�Union)�run_in_executor_with_context� )�Document)�Filter� to_filter)�Buffer)� Suggestion�AutoSuggest�ThreadedAutoSuggest�DummyAutoSuggest�AutoSuggestFromHistory�ConditionalAutoSuggest�DynamicAutoSuggestc �. � e Zd ZdZdeddfd�Zdefd�ZdS )r zb Suggestion returned by an auto-suggest algorithm. :param text: The suggestion text. �text�returnNc � � || _ d S �N�r )�selfr s �=/usr/lib/python3/dist-packages/prompt_toolkit/auto_suggest.py�__init__zSuggestion.__init__+ s � ��� � � � c � � d| j z S )NzSuggestion(%s)r )r s r �__repr__zSuggestion.__repr__. s � ��$�)�+�+r )�__name__� __module__�__qualname__�__doc__�strr r! � r r r r $ s[ � � � � � �� ��S� �T� � � � �,�#� ,� ,� ,� ,� ,� ,r r c �b � e Zd ZdZedddedee fd�� � Zdddedee fd�Z d S ) r z9 Base class for auto suggestion implementations. �bufferr �documentr c � � dS )a� Return `None` or a :class:`.Suggestion` instance. We receive both :class:`~prompt_toolkit.buffer.Buffer` and :class:`~prompt_toolkit.document.Document`. The reason is that auto suggestions are retrieved asynchronously. (Like completions.) The buffer text could be changed in the meantime, but ``document`` contains the buffer document like it was at the start of the auto suggestion call. So, from here, don't access ``buffer.text``, but use ``document.text`` instead. :param buffer: The :class:`~prompt_toolkit.buffer.Buffer` instance. :param document: The :class:`~prompt_toolkit.document.Document` instance. Nr'