← Back
Editing: prompt.cpython-311.pyc
� �Ïc�� � W �j � d Z ddlmZ ddlmZ ddlmZ ddlmZm Z m Z mZmZm Z mZmZmZmZ ddlmZ ddlmZ ddlmZmZ dd lmZ dd lmZmZmZ ddlm Z m!Z!m"Z" ddl#m$Z$m%Z%m&Z& dd l'm(Z( ddl)m*Z*m+Z+m,Z, ddl-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7 ddl8m9Z9m:Z:m;Z;m<Z<m=Z= ddl>m?Z?m@Z@ ddlAmBZB ddlCmDZD ddlEmFZF ddlGmHZH ddlImJZJmKZKmLZLmMZMmNZN ddlOmPZP ddlQmRZR ddlSmTZTmUZUmVZVmWZW ddlXmYZYmZZZ ddl[m\Z\m]Z]m^Z^ ddl_m`Z` ddlambZb ddlcmdZdmeZe dd lfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZq dd!lrmsZs dd"ltmuZumvZv dd#lwmxZxmyZymzZz dd$l{m|Z|m}Z}m~Z~mZm�Z�m�Z�m�Z� dd%l�m�Z�m�Z�m�Z�m�Z� dd&l�m�Z�m�Z� dd'l�m�Z�m�Z�m�Z� erdd(l�m�Z� g d)�Z�e g e:f Z�ePZ�d*e�d+ee g e�f e�e�f fd,�Z� G d-� d.eW� � Z� G d/� d0e�e� � Z�ee�d1e:e e�e�e�ge9f f Z� ed2� � Z� G d3� d4e e� � � Z� dhd5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d5d6d7d5d8�(d9e e9 d:e e? d;e e, d<e e� d=e e� d>e ev d?e e d@e e� dAe e� dBe eM dCe e9 dDe e| dEe ex dFe$dGe e1 dHe e� dIe e1 dJe e9 dKe e1 dLe e� dMe e1 dNe e1 dOe e1 dPe e1 dQe e1 dRe e� dSe e dTe e� dUe e dVe e1 dWe eeo dXe e9 dYe e� dZe e1 d[e e1 d\e e1 d]e ee�e g e�f f d^e ee�e g e�f f d_e�d`e�dae e g d5f d+e�fTdb�Z�e�j� j e�_ did9e�dde�d+e�e� fde�Z�djd9e�dde�d+e�fdg�Z�d5S )kao Line editing functionality. --------------------------- This provides a UI for a line input, similar to GNU Readline, libedit and linenoise. Either call the `prompt` function for every line input. Or create an instance of the :class:`.PromptSession` class and call the `prompt` method from that class. In the second case, we'll have a 'session' that keeps all the state like the history in between several calls. There is a lot of overlap between the arguments taken by the `prompt` function and the `PromptSession` (like `completer`, `style`, etcetera). There we have the freedom to decide which settings we want for the whole 'session', and which we want for an individual `prompt`. Example:: # Simple `prompt` call. result = prompt('Say something: ') # Using a 'session'. s = PromptSession() result = s.prompt('Say something: ') � )�contextmanager)�Enum)�partial) � TYPE_CHECKING�Callable�Generic�Iterator�List�Optional�Tuple�TypeVar�Union�cast)�Application)�get_app)�AutoSuggest�DynamicAutoSuggest)�Buffer)� Clipboard�DynamicClipboard�InMemoryClipboard)� Completer�DynamicCompleter�ThreadedCompleter)�AnyCursorShapeConfig�CursorShapeConfig�DynamicCursorShapeConfig)�Document)�DEFAULT_BUFFER� SEARCH_BUFFER�EditingMode)�get_event_loop)� Condition�FilterOrBool�has_arg� has_focus�is_done�is_true�renderer_height_is_known� to_filter)�AnyFormattedText�StyleAndTextTuples�fragment_list_to_text�merge_formatted_text�to_formatted_text)�History�InMemoryHistory)�Input)�load_auto_suggest_bindings��!display_completions_like_readline)�load_open_in_editor_bindings)�ConditionalKeyBindings�DynamicKeyBindings�KeyBindings�KeyBindingsBase�merge_key_bindings)� KeyPressEvent)�Keys)�Float�FloatContainer�HSplit�Window)�ConditionalContainer�WindowAlign)� BufferControl�FormattedTextControl�SearchBufferControl)� Dimension)�Layout)�CompletionsMenu�MultiColumnCompletionsMenu)� AfterInput�AppendAutoSuggestion�ConditionalProcessor�DisplayMultipleCursors�DynamicProcessor�#HighlightIncrementalSearchProcessor�HighlightSelectionProcessor�PasswordProcessor� Processor�ReverseSearchProcessor�merge_processors)�explode_text_fragments)�DynamicLexer�Lexer)� ColorDepth�DummyOutput�Output)� BaseStyle�ConditionalStyleTransformation�DynamicStyle�DynamicStyleTransformation�StyleTransformation�#SwapLightAndDarkStyleTransformation�merge_style_transformations)� get_cwidth�is_dumb_terminal�suspend_to_background_supported�to_str)�DynamicValidator� Validator)� SearchToolbar� SystemToolbar�ValidationToolbar)�MagicFormattedText)� PromptSession�prompt�confirm�create_confirm_session� CompleteStyle�get_prompt_text�returnc �\ � � dt f� fd�}dt f� fd�}dt f� fd�}|||fS )a6 Take a `get_prompt_text` function and return three new functions instead. One that tells whether this prompt consists of multiple lines; one that returns the fragments to be shown on the lines above the input; and another one with the fragments to be shown at the first line of the input. rs c �6 �� �� � D ]^} }}d|v r dS � dS )N� TF� )�fragment�char�_rr s ��A/usr/lib/python3/dist-packages/prompt_toolkit/shortcuts/prompt.py�has_before_fragmentsz5_split_multiline_prompt.<locals>.has_before_fragments� s; �� �"1�/�"3�"3� � ��H�d�Q��t�|�|��t�t� ��u� c � �� g } d}t t �� � � � � � D ](^}}}|r| � d||f� � � |dk rd}�)| S )NFr rv T��reversedrV �insert)�result�found_nlrx ry rz rr s �r{ �beforez'_split_multiline_prompt.<locals>.before� st �� �%'����"*�+A�/�/�BS�BS�+T�+T�"U�"U� � ��H�d�Q�� �� � �a�(�D�!1�2�2�2�2��������� r} c � �� g } t t �� � � � � � D ]%^}}}|dk r n| � d||f� � �&| S )Nrv r r )r� rx ry rz rr s �r{ �first_input_linez1_split_multiline_prompt.<locals>.first_input_line� sf �� �%'��"*�+A�/�/�BS�BS�+T�+T�"U�"U� 3� 3��H�d�Q��t�|�|���� � �a�(�D�!1�2�2�2�2�� r} )�boolr, )rr r| r� r� s ` r{ �_split_multiline_promptr� � s� �� ��$� � � � � � ��&� � � � � � ��0� � � � � � � ��)9�9�9r} c �, � � e Zd ZdZdeddf� fd�Z� xZS )�_RPromptzG The prompt that is displayed on the right side of the Window. �textrs Nc � �� t � � � t |�� � t j d�� � d S )N)r� z class:rprompt)�align�style)�super�__init__rE rC �RIGHT)�selfr� � __class__s �r{ r� z_RPrompt.__init__� sE �� � ����� �d�+�+�+��#�!� � � � � � r} )�__name__� __module__�__qualname__�__doc__r+ r� � __classcell__)r� s @r{ r� r� � sV �� � � � � �� � �-� �$� � � � � � � � � � r} r� c �* � e Zd ZU dZeed<