403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.25
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/prompt_toolkit/layout/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/prompt_toolkit/layout/__pycache__/processors.cpython-311.pyc
�

�ÏcV����dZddlZddlmZmZddlmZmZmZm	Z	m
Z
mZmZm
Z
mZddlmZddlmZddlmZddlmZmZmZdd	lmZmZmZdd
lmZmZddl m!Z!ddl"m#Z#m$Z$d
dl%m&Z&erd
dl'm(Z(m)Z)gd�Z*Gd�de���Z+ee,ge,fZ-ee,ge,fZ.Gd�d��Z/Gd�d��Z0Gd�de+��Z1Gd�de+��Z2Gd�de2��Z3Gd�de+��Z4Gd �d!e+��Z5Gd"�d#e+��Z6Gd$�d%e+��Z7Gd&�d'e+��Z8Gd(�d)e8��Z9Gd*�d+e+��Z:Gd,�d-e+��Z;Gd.�d/e+��Z<Gd0�d1e+��Z=Gd2�d3e+��Z>Gd4�d5e+��Z?Gd6�d7e+��Z@Gd8�d9e+��ZAd:e	e+d;e+fd<�ZBGd=�d>e+��ZCdS)?z�
Processors are little transformation blocks that transform the fragments list
from a buffer before the BufferControl will render it to the screen.

They can insert fragments before or after, or highlight fragments by replacing the
fragment types.
�N)�ABCMeta�abstractmethod)	�
TYPE_CHECKING�Callable�Hashable�List�Optional�Tuple�Type�Union�cast)�get_app)�SimpleCache)�Document)�FilterOrBool�	to_filter�vi_insert_multiple_mode)�AnyFormattedText�StyleAndTextTuples�to_formatted_text)�fragment_list_len�fragment_list_to_text)�SearchDirection)�to_int�to_str�)�explode_text_fragments)�
BufferControl�	UIContent)�	Processor�TransformationInput�Transformation�DummyProcessor�HighlightSearchProcessor�#HighlightIncrementalSearchProcessor�HighlightSelectionProcessor�PasswordProcessor�!HighlightMatchingBracketProcessor�DisplayMultipleCursors�BeforeInput�ShowArg�
AfterInput�AppendAutoSuggestion�ConditionalProcessor�ShowLeadingWhiteSpaceProcessor�ShowTrailingWhiteSpaceProcessor�
TabsProcessor�ReverseSearchProcessor�DynamicProcessor�merge_processorsc�2�eZdZdZe				dd���ZdS)	r zt
    Manipulate the fragments for a given line in a
    :class:`~prompt_toolkit.layout.controls.BufferControl`.
    �transformation_inputr!�returnr"c�*�t|j��S)z�
        Apply transformation. Returns a :class:`.Transformation` instance.

        :param transformation_input: :class:`.TransformationInput` object.
        �r"�	fragments��selfr6s  �B/usr/lib/python3/dist-packages/prompt_toolkit/layout/processors.py�apply_transformationzProcessor.apply_transformationGs���2�<�=�=�=�N)r6r!r7r")�__name__�
__module__�__qualname__�__doc__rr>�r?r=r r AsN��������
�>�$9�>�	�>�>�>��^�>�>�>r?r )�	metaclassc�`�eZdZdZdddededededed	ed
dfd�Zd
e	deeeeeeffd
�Z
dS)r!a�
    :param buffer_control: :class:`.BufferControl` instance.
    :param lineno: The number of the line to which we apply the processor.
    :param source_to_display: A function that returns the position in the
        `fragments` for any position in the source string. (This takes
        previous processors into account.)
    :param fragments: List of fragments that we can transform. (Received from the
        previous processor.)
    �buffer_controlr�document�lineno�source_to_displayr:�width�heightr7Nc�h�||_||_||_||_||_||_||_dS�N�rGrHrIrJr:rKrL)r<rGrHrIrJr:rKrLs        r=�__init__zTransformationInput.__init__bs;��-��� ��
����!2���"�����
�����r?c�Z�|j|j|j|j|j|j|jfSrNrO�r<s r=�unpackzTransformationInput.unpackus3��
���M��K��"��N��J��K�
�	
r?)r@rArBrCr�int�SourceToDisplayrrPr
rSrDr?r=r!r!Ws����������'�����	�
+��&�
�����
�����&

�	���3��9K�S�RU�U�
�

�

�

�

�

�

r?r!c	�H�eZdZdZ		ddedeedeeddfd�ZdS)	r"a)
    Transformation result, as returned by :meth:`.Processor.apply_transformation`.

    Important: Always make sure that the length of `document.text` is equal to
               the length of all the text in `fragments`!

    :param fragments: The transformed fragments. To be displayed, or to pass to
        the next processor.
    :param source_to_display: Cursor position transformation from original
        string to transformed string.
    :param display_to_source: Cursor position transformed from source string to
        original string.
    Nr:rJ�display_to_sourcer7c�<�||_|pd�|_|pd�|_dS)Nc��|SrNrD��is r=�<lambda>z)Transformation.__init__.<locals>.<lambda>�����r?c��|SrNrDrZs r=r\z)Transformation.__init__.<locals>.<lambda>�r]r?)r:rJrW)r<r:rJrWs    r=rPzTransformation.__init__�s/��#���!2�!C�{�{���!2�!C�{�{����r?)NN)	r@rArBrCrr	rU�DisplayToSourcerPrDr?r=r"r"�sz��������"8<�7;�		D�	D�%�	D�$�O�4�	D�$�O�4�		D�

�	D�	D�	D�	D�	D�	Dr?r"c�"�eZdZdZdedefd�ZdS)r#z1
    A `Processor` that doesn't do anything.
    r6r7c�*�t|j��SrNr9r;s  r=r>z#DummyProcessor.apply_transformation�s���2�<�=�=�=r?N�r@rArBrCr!r"r>rDr?r=r#r#�sB��������>�$7�>�	�>�>�>�>�>�>r?r#c�:�eZdZdZdZdZdddefd�Zdede	fd	�Z
d
S)r$z�
    Processor that highlights search matches in the document.
    Note that this doesn't support multiline search matches yet.

    The style classes 'search' and 'search.current' will be applied to the
    content.
    �searchzsearch.currentrGrr7c��|jjS)�0
        The text we are searching for.
        )�search_state�text)r<rGs  r=�_get_search_textz)HighlightSearchProcessor._get_search_text�s���*�/�/r?r6c�t�|���\}}}}}}}|�|��}d|j�d�}	d|j�d�}
|�r`t	��j�sLt
|��}t|��}|j�	��r
tj}ntjd��}|j
|kr||j��}
nd}
tjtj|��||���D]�}|
�5|���|
cxko|���knc}nd}t'|���|�����D]<}||^}}}|r||
z||df||<�&||	z||df||<�=��t)|��S)Nz class:� r)�flagsFr)rSri�
_classname�_classname_currentr�is_donerrrg�ignore_case�re�
IGNORECASE�	RegexFlag�cursor_position_row�cursor_position_col�finditer�escape�start�end�ranger")r<r6rGrHrIrJr:�_�search_text�searchmatch_fragment�searchmatch_current_fragment�	line_textrl�
cursor_column�match�	on_cursorr[�old_fragmentrhs                   r=r>z-HighlightSearchProcessor.apply_transformation�s���
!�'�'�)�)�	
������
�
��+�+�N�;�;��;���;�;�;��'K��1H�'K�'K�'K�$��"	�w�y�y�0�"	�-�i�8�8�I�.�y�9�9�I��*�6�6�8�8�
(��
�����Q�����+�v�5�5� 1� 1�(�2N� O� O�
�
� $�
���R�Y�{�%;�%;�Y�e�T�T�T�
�
�� �,� %���
�
�� L� L� L� L������ L� L� L� L�I�I� %�I��u�{�{�}�}�e�i�i�k�k�:�:���A�-6�q�\�*�L�$�� �	�(�+G�G�%�a�L��O�(�	�!���)�+?�?�%�a�L��O�(�	�!�����i�(�(�(r?N)r@rArBrCrmrn�strrir!r"r>rDr?r=r$r$�sq���������J�)��0��0�3�0�0�0�0�6)�$7�6)�	�6)�6)�6)�6)�6)�6)r?r$c�*�eZdZdZdZdZdddefd�ZdS)	r%ai
    Highlight the search terms that are used for highlighting the incremental
    search. The style class 'incsearch' will be applied to the content.

    Important: this requires the `preview_search=True` flag to be set for the
    `BufferControl`. Otherwise, the cursor position won't be set to the search
    match while searching, and nothing happens.
    �	incsearchzincsearch.currentrGrr7c�4�|j}|�|jr|jSdS)rfN�)�
search_bufferrh)r<rGr�s   r=riz4HighlightIncrementalSearchProcessor._get_search_texts(��
'�4�
��$��);�$� �%�%��rr?N)r@rArBrCrmrnr�rirDr?r=r%r%�sM���������J�,�����3������r?r%c�"�eZdZdZdedefd�ZdS)r&zB
    Processor that highlights the selection in the document.
    r6r7c��|���\}}}}}}}d}|�|��}	|	r�|	\}
}||
��}
||��}t|��}|
dkr+|dkr%t|��dkrt	|dfg��St|
|��D]U}|t|��kr||^}
}}|
|z|f||<�+|t|��kr|�|df���Vt	|��S)Nz class:selected rrk)rS�selection_range_at_liner�lenr"rz�append)r<r6rGrHrIrJr:r{�selected_fragment�selection_at_line�from_�tor[r��old_texts               r=r>z0HighlightSelectionProcessor.apply_transformationsP��
!�'�'�)�)�	
������
�
�/��%�<�<�V�D�D���	C�)�I�E�2�%�%�e�,�,�E�"�"�2�&�&�B�.�y�9�9�I���z�z�b�A�g�g�#�i�.�.�A�*=�*=�&�(9�3�'?�&@�A�A�A��u�b�)�)�C�C�A��3�y�>�>�)�)�5>�q�\�2��h��(4�7H�(H�(�'S�	�!����c�)�n�n�,�,�!�(�(�*;�S�)A�B�B�B���i�(�(�(r?NrbrDr?r=r&r&sB��������%)�$7�%)�	�%)�%)�%)�%)�%)�%)r?r&c�4�eZdZdZd	deddfd�Zdedefd�ZdS)
r'z{
    Processor that masks the input. (For passwords.)

    :param char: (string) Character to be used. "*" by default.
    �*�charr7Nc��||_dSrN)r�)r<r�s  r=rPzPasswordProcessor.__init__Bs
����	�	�	r?�tic�n��tt�fd�|jD����}t|��S)Nc�N��g|]!^}}}|�jt|��zg|�R��"SrD)r�r�)�.0�stylerh�handlerr<s    �r=�
<listcomp>z:PasswordProcessor.apply_transformation.<locals>.<listcomp>HsI���
�
�
�)�E�4�'���	�C��I�I�-�8��8�8�
�
�
r?)r
rr:r")r<r�r:s`  r=r>z&PasswordProcessor.apply_transformationEsM���(,��
�
�
�
�-/�\�
�
�
�)
�)
�	��i�(�(�(r?)r��	r@rArBrCr�rPr!r"r>rDr?r=r'r';sh����������S��4�����	)�':�	)�~�	)�	)�	)�	)�	)�	)r?r'c�j�eZdZdZdZ	ddededdfd	�Zd
ede	e
eeffd�Zdede
fd
�ZdS)r(a�
    When the cursor is on or right after a bracket, it highlights the matching
    bracket.

    :param max_cursor_distance: Only highlight matching brackets when the
        cursor is within this distance. (From inside a `Processor`, we can't
        know which lines will be visible on the screen. But we also don't want
        to scan the whole document for matching brackets on each key press, so
        we limit to this value.)
    z])}>�[](){}<>���chars�max_cursor_distancer7Nc�L�||_||_td���|_dS)N�)�maxsize)r�r�r�_positions_cache)r<r�r�s   r=rPz*HighlightMatchingBracketProcessor.__init___s1����
�#6�� �
��"�"�"�	
���r?rHc���|jr@|j|jvr2|�|j|jz
|j|jz���}nt|jrk|j|jvr]|j|jvrOt|j|jdz
��}|�|j|jz
|j|jz���}nd}|r4||jz
}|�	|��\}}||f|j
|jfgSgS)zQ
        Return a list of (row, col) tuples that need to be highlighted.
        )�	start_pos�end_posrN)�current_charr��find_matching_bracket_position�cursor_positionr��char_before_cursor�_closing_bracesrrh�translate_index_to_positionrtru)r<rH�pos�row�cols     r=�_get_positions_to_highlightz=HighlightMatchingBracketProcessor._get_positions_to_highlightis0��� �	�X�%:�d�j�%H�%H��9�9�"�2�T�5M�M� �0�4�3K�K�:���C�C�
�'�	��+�t�/C�C�C��+�t�z�9�9���
�x�/G�!�/K�L�L�H��9�9�"�2�T�5M�M� �0�4�3K�K�:���C�C�
�C��	��8�+�+�C��;�;�C�@�@�H�C���c�
��-�x�/K�L��
�
�Ir?r6c����
�|���\}�
}}}}}t��jrt|��St��j�
j�
jf}�j�|�
�fd���}|rP|D]M\}	}
|	|krB||
��}
t|��}||
^}}}|
�
j
kr|dz
}n|dz
}||f||
<�Nt|��S)Nc�.�������SrN)r�)rHr<s��r=r\zHHighlightMatchingBracketProcessor.apply_transformation.<locals>.<lambda>�s����9�9�(�C�C�r?z class:matching-bracket.cursor z class:matching-bracket.other )rSrror"�render_counterrhr�r��getrru)r<r6rGrIrJr:r{�key�	positionsr�r�r�rhrHs`            @r=r>z6HighlightMatchingBracketProcessor.apply_transformation�s&����
!�'�'�)�)�	
������
�
��9�9��	-�!�)�,�,�,��y�y�'����8P�Q���)�-�-��C�C�C�C�C�
�
�	�
�	3�%�
3�
3���S��&�=�=�+�+�C�0�0�C� 6�y� A� A�I�&/��n�O�E�4�!��h�:�:�:��!B�B����!A�A��&+�T�]�I�c�N���i�(�(�(r?)r�r�)r@rArBrCr�r�rTrPrrr
r�r!r"r>rDr?r=r(r(Qs�������	�	��O�CG�#�#��#�<?�#�	
�#�#�#�#�%�H�%��e�C�QT�H�o�AV�%�%�%�%�N')�$7�')�	�')�')�')�')�')�')r?r(c�"�eZdZdZdedefd�ZdS)r)zF
    When we're in Vi block insert mode, display all the cursors.
    r6r7c��|���\}}}}}}}|j}t��r�|j}	t	|��}|�|d��}
|
t
|j|��z}d}|	D]`}
|
|
cxkr|krQn�||
|
z
��}	||^}}}||z
}||f||<�9#t$r|�	|df��Y�\wxYw�at|��St|��S)Nrz class:multiple-cursorsrk)rS�bufferr�multiple_cursor_positionsr�translate_row_col_to_indexr��lines�
IndexErrorr�r")r<r6rGrHrIrJr:r{�buff�cursor_positionsr�r��fragment_suffix�p�columnr�rhs                 r=r>z+DisplayMultipleCursors.apply_transformation�sj��
!�'�'�)�)�	
������
�
��$��"�$�$�	-�#�=��.�y�9�9�I�!�;�;�F�A�F�F�I��#�h�n�V�&<�"=�"=�=�G�7�O�%�
:�
:����,�,�,�,�W�,�,�,�,�,�.�.�q�9�}�=�=�F�:�*3�F�*;���t�a�
��0��-2�D�M�	�&�)�)��&�A�A�A�!�(�(�/�3�)?�@�@�@�@�@�A����
-�"�)�,�,�,�!�)�,�,�,s� B8�8!C�CNrbrDr?r=r)r)�sB��������*-�$7�*-�	�*-�*-�*-�*-�*-�*-r?r)c�D�eZdZdZddededdfd�Zdedefd	�Z	defd
�Z
dS)r*z�
    Insert text before the input.

    :param text: This can be either plain text or formatted text
        (or a callable that returns any of those).
    :param style: style to be applied to this prompt/prefix.
    r�rhr�r7Nc�"�||_||_dSrN�rhr��r<rhr�s   r=rPzBeforeInput.__init__������	���
�
�
r?r�c����|jdkr>t|j|j��}||jz}t|����fd�}�fd�}n|j}d}d}t
|||���S)Nrc���|�zSrNrD�r[�shift_positions �r=r\z2BeforeInput.apply_transformation.<locals>.<lambda>����!�n�*<�r?c���|�z
SrNrDr�s �r=r\z2BeforeInput.apply_transformation.<locals>.<lambda>r�r?�rJrW)rIrrhr�r:rr")r<r��fragments_beforer:rJrWr�s      @r=r>z BeforeInput.apply_transformation�s�����9��>�>�0���D�J�G�G��(�2�<�7�I�.�/?�@�@�N� <� <� <� <�� <� <� <� <�����I� $�� $����/�/�
�
�
�	
r?c�(�d|j�d|j�d�S)NzBeforeInput(z, �)r�rRs r=�__repr__zBeforeInput.__repr__s��<�d�i�<�<�T�Z�<�<�<�<r?�r��r@rArBrCrr�rPr!r"r>r�rDr?r=r*r*�s�����������-��c��4�����
�':�
�~�
�
�
�
�.=�#�=�=�=�=�=�=r?r*c�<��eZdZdZd�fd�Zdefd�Zdefd�Z�xZ	S)r+z�
    Display the 'arg' in front of the input.

    This was used by the `PromptSession`, but now it uses the
    `Window.get_line_prefix` function instead.
    r7Nc�T��t���|j��dSrN)�superrP�_get_text_fragments)r<�	__class__s �r=rPzShowArg.__init__s$���
������1�2�2�2�2�2r?c�z�t��}|jj�gS|jj}ddt|��fdgS)N)�class:prompt.argz(arg: zclass:prompt.arg.text)r�z) )r�
key_processor�argr�)r<�appr�s   r=r�zShowArg._get_text_fragmentssG���i�i���� �(��I��#�'�C�/�(�#�c�(�(�3�*��
r?c��dS)Nz	ShowArg()rDrRs r=r�zShowArg.__repr__,s���{r?)r7N)
r@rArBrCrPrr�r�r��
__classcell__)r�s@r=r+r+s~���������3�3�3�3�3�3��%7������#��������r?r+c�D�eZdZdZddededdfd�Zdedefd	�Z	defd
�Z
dS)r,z�
    Insert text after the input.

    :param text: This can be either plain text or formatted text
        (or a callable that returns any of those).
    :param style: style to be applied to this prompt/prefix.
    r�rhr�r7Nc�"�||_||_dSrNr�r�s   r=rPzAfterInput.__init__9r�r?r�c��|j|jjdz
kr2t|j|j��}t
|j|z���St
|j���S)Nr�r:)rIrH�
line_countrrhr�r"r:)r<r��fragments_afters   r=r>zAfterInput.apply_transformation=sW��
�9���.��2�2�2�/��	�4�:�F�F�O�!�B�L�?�,J�K�K�K�K�!�B�L�9�9�9�9r?c�@�|jj�d|j�d|j�d�S)N�(z, style=r�)r�r@rhr�rRs r=r�zAfterInput.__repr__Fs*���.�)�P�P�D�I�P�P���P�P�P�Pr?r�r�rDr?r=r,r,0s�����������-��c��4�����:�':�:�~�:�:�:�:�Q�#�Q�Q�Q�Q�Q�Qr?r,c�4�eZdZdZd	deddfd�Zdedefd�ZdS)
r-z{
    Append the auto suggestion to the input.
    (The user can then press the right arrow the insert the suggestion.)
    �class:auto-suggestionr�r7Nc��||_dSrN)r�)r<r�s  r=rPzAppendAutoSuggestion.__init__Ps
����
�
�
r?r�c��|j|jjdz
krN|jj}|jr|jjr
|jj}nd}t|j	|j
|fgz���St|j	���S)Nrr�r�)rIrHr�rGr��
suggestion�is_cursor_at_the_endrhr"r:r�)r<r�r�r�s    r=r>z)AppendAutoSuggestion.apply_transformationSs���
�9���.��2�2�2��&�-�F�� �
 �R�[�%E�
 �#�.�3�
�
��
�!�B�L�T�Z��<T�;U�,U�V�V�V�V�!�B�L�9�9�9�9r?)r�r�rDr?r=r-r-Jsh��������
��c�������:�':�:�~�:�:�:�:�:�:r?r-c�X�eZdZdZ		d
deegefdeddfd�Zdede	fd	�Z
dS)r/ze
    Make leading whitespace visible.

    :param get_char: Callable that returns one character.
    N�class:leading-whitespace�get_charr�r7c�<�dtfd�}||_|p||_dS)Nr7c��d�t��j���d��dkrdSdS�N�·�replace�?�.��encoder�output�encodingrDr?r=�default_get_charzAShowLeadingWhiteSpaceProcessor.__init__.<locals>.default_get_charn�8���}�}�W�Y�Y�-�6�6�8�8�)�D�D��L�L��s��vr?�r�r�r��r<r�r�rs    r=rPz'ShowLeadingWhiteSpaceProcessor.__init__i�7��
	�#�	�	�	�	���
� �4�$4��
�
�
r?r�c�8�|j}|r�t|���d��ra|j|���f}t|��}t
t|����D]}||ddkr|||<�t|��S)Nrkr)	r:r�
startswithr�r�rrzr�r")r<r�r:�tr[s     r=r>z3ShowLeadingWhiteSpaceProcessor.apply_transformationws����L�	��	�.�y�9�9�D�D�S�I�I�	���T�]�]�_�_�-�A�.�y�9�9�I��3�y�>�>�*�*�
�
���Q�<��?�c�)�)�#$�I�a�L�L���i�(�(�(r?)Nr��r@rArBrCr	rr�rPr!r"r>rDr?r=r/r/bs���������15�/�5�5��8�B��G�,�-�5��5�
�	5�5�5�5�)�':�)�~�)�)�)�)�)�)r?r/c�X�eZdZdZ		d
deegefdeddfd�Zdede	fd	�Z
dS)r0zf
    Make trailing whitespace visible.

    :param get_char: Callable that returns one character.
    N�class:training-whitespacer�r�r7c�<�dtfd�}||_|p||_dS)Nr7c��d�t��j���d��dkrdSdSr�r�rDr?r=rzBShowTrailingWhiteSpaceProcessor.__init__.<locals>.default_get_char�rr?rrs    r=rPz(ShowTrailingWhiteSpaceProcessor.__init__�rr?r�c�D�|j}|r�|dd�d��rh|j|���f}t	|��}tt
|��dz
dd��D]}||d}|dkr|||<�t|��S)N���rrk)r:�endswithr�r�rrzr�r")r<r�r:r	r[r�s      r=r>z4ShowTrailingWhiteSpaceProcessor.apply_transformation�s����L�	��
	��2��q�)�2�2�3�7�7�
	���T�]�]�_�_�-�A�.�y�9�9�I��3�y�>�>�A�-�r�2�6�6�
�
�� ��|�A����3�;�;�#$�I�a�L�L���i�(�(�(r?)Nrr
rDr?r=r0r0�s���������15�0�5�5��8�B��G�,�-�5��5�
�	5�5�5�5�)�':�)�~�)�)�)�)�)�)r?r0c��eZdZdZ				ddeeegeffdeeegeffdeeegeffd	ed
df
d�Zd
e	d
e
fd�ZdS)r1a�
    Render tabs as spaces (instead of ^I) or make them visible (for instance,
    by replacing them with dots.)

    :param tabstop: Horizontal space taken by a tab. (`int` or callable that
        returns an `int`).
    :param char1: Character or callable that returns a character (text of
        length one). This one is used for the first space taken by the tab.
    :param char2: Like `char1`, but for the rest of the space.
    ��|�┈�	class:tab�tabstop�char1�char2r�r7Nc�>�||_||_||_||_dSrN)rrrr�)r<rrrr�s     r=rPzTabsProcessor.__init__�s$����
���
������
�
�
r?r�c���t|j��}|j}t|j��}t|j��}t
|j��}i�g}d}t|��D]z\}	}
|�|	<|
ddkrJ|||zz
}|dkr|}|�	||f��|�	|||dz
zf��||z
}�`|�	|
��|dz
}�{|�t|��<|dz�t|��dz<dtdtf�fd�}dtdtf�fd�}
t|||
�	��S)
Nrr�	�
from_positionr7c����|S)z-Maps original cursor position to the new one.rD)r�position_mappingss �r=rJz=TabsProcessor.apply_transformation.<locals>.source_to_display�s���$�]�3�3r?�display_posc���d�����D��}|dkr$	||S#t$r|dz}YnwxYw|dk�$dS)z1Maps display cursor position to the original one.c��i|]\}}||��	SrDrD)r��k�vs   r=�
<dictcomp>zQTabsProcessor.apply_transformation.<locals>.display_to_source.<locals>.<dictcomp>�s��)U�)U�)U�4�1�a�!�Q�)U�)U�)Ur?rr)�items�KeyError)r �position_mappings_reversedrs  �r=rWz=TabsProcessor.apply_transformation.<locals>.display_to_source�s|���)U�)U�;L�;R�;R�;T�;T�)U�)U�)U�&���"�"�%�5�k�B�B���%�%�%��1�$�K�K�K�%������"�"�
�1s�/�A�Ar�)
rrr�rrrrr:�	enumerater�r�rTr")r<r�rr��
separator1�
separator2r:�result_fragmentsr�r[�fragment_and_text�countrJrWrs              @r=r>z"TabsProcessor.apply_transformation�s�������&�&���
���D�J�'�'�
��D�J�'�'�
�+�2�<�8�8�	���/1����$-�i�$8�$8�	�	� �A� �#&��a� � ��#�t�+�+��3��=�1���A�:�:�#�E�!�'�'��
�(;�<�<�<� �'�'��
�e�a�i�0H�(I�J�J�J��u���� �'�'�(9�:�:�:��q����,/��#�i�.�.�)�14�a���#�i�.�.�1�,�-�	4�S�	4�S�	4�	4�	4�	4�	4�	4�		�3�		�3�		�		�		�		�		�		���/�/�
�
�
�	
r?)rrrr)r@rArBrCrrTrr�rPr!r"r>rDr?r=r1r1�s�������	�	�23�/2�/7� ����s�H�R��W�-�-�.���S�(�2�s�7�+�+�,���S�(�2�s�7�+�+�,�	�
��
�
����8
�':�8
�~�8
�8
�8
�8
�8
�8
r?r1c��eZdZUdZeeeegZe	e
eed<ddde
dfd�Zdddedd	fd
�Zdedefd�ZdS)
r2z�
    Process to display the "(reverse-i-search)`...`:..." stuff around
    the search buffer.

    Note: This processor is meant to be applied to the BufferControl that
    contains the search buffer, it's not meant for the original input.
    �_excluded_input_processorsrGrr7c�|�ddlm}t��jj}t||��r
|j|kr|SdS)Nr�r)�prompt_toolkit.layout.controlsrr�layout�search_target_buffer_control�
isinstance�search_buffer_control)r<rGr�prev_controls    r=�_get_main_bufferz'ReverseSearchProcessor._get_main_buffersQ��	A�@�@�@�@�@��y�y�'�D���|�]�3�3�	 ��2�n�D�D����tr?�main_controlr�rc��	�
�ddlm}t|j���	dtdt
tf�	�
fd��
�
t
|jpg����}t��}|r||g}n|g}ddl	m
}t|j|��sJ�||j
|d|jd	|j�
��}|�|j|jd	���S)Nrr2�itemr7c�(��t|t��r,�fd�|jD��}td�|D����St|t��r(�|j��}|rt	||j��Snt|���s|SdS)z�Filter processors from the main control that we want to disable
            here. This returns either an accepted processor or None.c�&��g|]
}�|����SrDrD)r�r��filter_processors  �r=r�zMReverseSearchProcessor._content.<locals>.filter_processor.<locals>.<listcomp>.s%���&T�&T�&T�q�'7�'7��':�':�&T�&T�&Tr?c��g|]}|�|��SrNrD)r�r�s  r=r�zMReverseSearchProcessor._content.<locals>.filter_processor.<locals>.<listcomp>0s��E�E�E�1�q�}�Q�}�}�}r?N)r6�_MergedProcessor�
processorsr4r.�	processor�filter)r<�accepted_processorsr��excluded_processorsr?s   ��r=r?z9ReverseSearchProcessor._content.<locals>.filter_processor)s�����$� 0�1�1�
 �&T�&T�&T�&T�D�O�&T�&T�&T�#�'�E�E� 3�E�E�E����
�D�"6�7�7�
 �$�$�T�^�4�4���@�/��4�;�?�?�?�@�
"�$�(;�<�<� ��K��4r?r��SearchBufferControlFT)r��input_processors� include_default_input_processors�lexer�preview_searchr7)rL)r3r�tupler0r r	r4rIr%�controlsrHr6rGr�rK�create_contentrKrL)r<r:r�r�filtered_processor�highlight_processor�new_processorsrHrGrFr?s         @@r=�_contentzReverseSearchProcessor._content s5����	A�@�@�@�@�@�$�D�$C�D�D��	�9�	��)�1D�	�	�	�	�	�	�	�..�-��\�:�@�b�A�A�
�
��B�C�C���	3�0�2E�F�N�N�1�2�N�1�1�1�1�1�1��"�+�-@�A�A�A�A�A�&���&�+�-2��$��"$�"3�

�
�
���,�,�R�X�r�y�QU�,�V�V�Vr?c���ddlm}t|j|��s
Jd���|�|j��}|jdkr�|r�|�||��}|�|jj	��}|j
jtj
krd}nd}dd|fd	g}|d
t|j��fdgz|z}t!|����fd�}	�fd
�}
nd}	d}
|j}t#||	|
���S)NrrGzK`ReverseSearchProcessor` should be applied to a `SearchBufferControl` only.rzi-searchzreverse-i-search)�class:prompt.searchr�rU)rUz)`zclass:prompt.search.text)r�z': c���|�zSrNrDr�s �r=r\z=ReverseSearchProcessor.apply_transformation.<locals>.<lambda>�r�r?c���|�z
SrNrDr�s �r=r\z=ReverseSearchProcessor.apply_transformation.<locals>.<lambda>�r�r?r�)rNrHr6rGr9rIrS�get_liner��yrg�	directionr�FORWARDrr:rr")r<r�rHr:�content�line_fragments�direction_textr�r:rJrWr�s           @r=r>z+ReverseSearchProcessor.apply_transformationYsq���1�1�1�1�1�1����2�
�
�	Y�	Y�X�	Y�	Y�	Y��,�,�R�->�?�?��
�9��>�>�l�>��m�m�L�"�5�5�G�%�-�-�g�.E�.G�H�H�N��(�2�o�6M�M�M�!+���!3��-�&��7�-�4��!�/�1F�r�|�1T�1T�U����
!�!�
�/�/?�@�@�N� <� <� <� <�� <� <� <� <��� $�� $����I���/�/�
�
�
�	
r?N)r@rArBrCr$r&r*r,r0rrr �__annotations__r	r9r!rSr"r>rDr?r=r2r2s����������	!�#���	9���T�)�_� 5�����-��	�/�	"�����7W�+�7W�1D�7W�	�7W�7W�7W�7W�r2
�':�2
�~�2
�2
�2
�2
�2
�2
r?r2c�B�eZdZdZdededdfd�Zdedefd�Z	de
fd	�ZdS)
r.a�
    Processor that applies another processor, according to a certain condition.
    Example::

        # Create a function that returns whether or not the processor should
        # currently be applied.
        def highlight_enabled():
            return true_or_false

        # Wrapped it in a `ConditionalProcessor` for usage in a `BufferControl`.
        BufferControl(input_processors=[
            ConditionalProcessor(HighlightSearchProcessor(),
                                 Condition(highlight_enabled))])

    :param processor: :class:`.Processor` instance.
    :param filter: :class:`~prompt_toolkit.filters.Filter` instance.
    rCrDr7Nc�<�||_t|��|_dSrN)rCrrD)r<rCrDs   r=rPzConditionalProcessor.__init__�s��"�����'�'����r?r6c��|���r|j�|��St|j��SrN)rDrCr>r"r:r;s  r=r>z)ConditionalProcessor.apply_transformation�s>���;�;�=�=�	B��>�6�6�7K�L�L�L�!�"6�"@�A�A�Ar?c�X�d�|jj|j|j��S)Nz{}(processor={!r}, filter={!r}))�formatr�r@rCrDrRs r=r�zConditionalProcessor.__repr__�s,��0�7�7��N�#��N��K�
�
�	
r?)r@rArBrCr rrPr!r"r>r�r�rDr?r=r.r.�s���������$(�)�(�\�(�d�(�(�(�(�B�$7�B�	�B�B�B�B�
�#�
�
�
�
�
�
r?r.c�N�eZdZdZdegeefddfd�Zdede	fd�Z
dS)r3z�
    Processor class that dynamically returns any Processor.

    :param get_processor: Callable that returns a :class:`.Processor` instance.
    �
get_processorr7Nc��||_dSrN)rf)r<rfs  r=rPzDynamicProcessor.__init__�s��*����r?r�c�p�|���p
t��}|�|��SrN)rfr#r>)r<r�rCs   r=r>z%DynamicProcessor.apply_transformation�s2���&�&�(�(�<�N�,<�,<�	��-�-�b�1�1�1r?)r@rArBrCrr	r rPr!r"r>rDr?r=r3r3�sr��������+�h�r�8�I�3F�/F�&G�+�D�+�+�+�+�2�':�2�~�2�2�2�2�2�2r?r3rBr7c��t|��dkrt��St|��dkr|dSt|��S)z6
    Merge multiple `Processor` objects into one.
    rr)r�r#rA�rBs r=r4r4�sJ���:���!�������
�:���!����!�}���J�'�'�'r?c�:�eZdZdZdeefd�Zdedefd�Z	dS)rAzw
    Processor that groups multiple other `Processor` objects, but exposes an
    API as if it is one `Processor`.
    rBc��||_dSrNrj)r<rBs  r=rPz_MergedProcessor.__init__�s
��$����r?r�r7c����|jg�g�|j}dtdtf�fd�}|jD]~}|�t|j|j|j|||j	|j
����}|j}��|j����|j���dtdtf�fd�}�dd�=t|||��S)Nr[r7c�(���D]
}||��}�|S)zcTranslate x position from the buffer to the x position in the
            processor fragments list.rD)r[�f�source_to_display_functionss  �r=rJz@_MergedProcessor.apply_transformation.<locals>.source_to_display�s(���1�
�
���A�a�D�D����Hr?c�B��t���D]
}||��}�|SrN)�reversed)r[ro�display_to_source_functionss  �r=rWz@_MergedProcessor.apply_transformation.<locals>.display_to_source�s/����9�:�:�
�
���A�a�D�D����Hr?r)rJr:rTrBr>r!rGrHrIrKrLr�rWr")	r<r�r:rJr��transformationrWrsrps	       @@r=r>z%_MergedProcessor.apply_transformation�s)����')�';�&<�#�&(�#��L�	�	��	��	�	�	�	�	�	���	Q�	Q�A��3�3�#��%��K��I�%���H��I���
�
�N�'�0�I�'�.�.�~�/O�P�P�P�'�.�.�~�/O�P�P�P�P�	��	��	�	�	�	�	�	�
(����+��i�):�<M�N�N�Nr?N)
r@rArBrCrr rPr!r"r>rDr?r=rArA�sh��������
%�4�	�?�%�%�%�%�*O�':�*O�~�*O�*O�*O�*O�*O�*Or?rA)DrCrq�abcrr�typingrrrrr	r
rrr
�"prompt_toolkit.application.currentr�prompt_toolkit.cacher�prompt_toolkit.documentr�prompt_toolkit.filtersrrr�prompt_toolkit.formatted_textrrr�#prompt_toolkit.formatted_text.utilsrr�prompt_toolkit.searchr�prompt_toolkit.utilsrr�utilsrrNrr�__all__r rTrUr_r!r"r#r$r%r&r'r(r)r*r+r,r-r/r0r1r2r.r3r4rArDr?r=�<module>r�s�����
�	�	�	�'�'�'�'�'�'�'�'�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�7�6�6�6�6�6�,�,�,�,�,�,�,�,�,�,�,�,�S�S�S�S�S�S�S�S�S�S�����������
Y�X�X�X�X�X�X�X�1�1�1�1�1�1�/�/�/�/�/�/�/�/�)�)�)�)�)�)��3�2�2�2�2�2�2�2�2�����2>�>�>�>�>�'�>�>�>�>�$�C�5�#�:�&���C�5�#�:�&��+
�+
�+
�+
�+
�+
�+
�+
�\D�D�D�D�D�D�D�D�6>�>�>�>�>�Y�>�>�>�H)�H)�H)�H)�H)�y�H)�H)�H)�V�����*B����0*)�*)�*)�*)�*)�)�*)�*)�*)�Z)�)�)�)�)�	�)�)�)�,f)�f)�f)�f)�f)�	�f)�f)�f)�R/-�/-�/-�/-�/-�Y�/-�/-�/-�d%=�%=�%=�%=�%=�)�%=�%=�%=�P�����k����8Q�Q�Q�Q�Q��Q�Q�Q�4:�:�:�:�:�9�:�:�:�0#)�#)�#)�#)�#)�Y�#)�#)�#)�L$)�$)�$)�$)�$)�i�$)�$)�$)�NQ
�Q
�Q
�Q
�Q
�I�Q
�Q
�Q
�hH
�H
�H
�H
�H
�Y�H
�H
�H
�V%
�%
�%
�%
�%
�9�%
�%
�%
�P2�2�2�2�2�y�2�2�2�
(��i��
(�Y�
(�
(�
(�
(�3O�3O�3O�3O�3O�y�3O�3O�3O�3O�3Or?

Youez - 2016 - github.com/yon3zu
LinuXploit