Current File : //usr/local/apps/python3/lib/python3.11/idlelib/__pycache__/parenmatch.cpython-311.opt-1.pyc
�

�Ke$���dZddlmZddlmZdddd�ZdZGd	�d
��Ze���e	dkrddl
mZed
d���dSdS)z�ParenMatch -- for parenthesis matching.

When you hit a right paren, the cursor should move briefly to the left
paren.  Paren here is used generically; the matching applies to
parentheses, square brackets, and curly braces.
�)�HyperParser)�idleConf�(�[�{��)�]�}�dc��eZdZdZdZdZd�Zed���Zd�Z	d�Z
d�Zd	�Zd
�Z
dd�Zd
�Zd�Zd�Zd�Zeeeed�Zd�Zd�ZdS)�
ParenMatcha'Highlight matching openers and closers, (), [], and {}.

    There are three supported styles of paren matching.  When a right
    paren (opener) is typed:

    opener -- highlight the matching left paren (closer);
    parens -- highlight the left and right parens (opener and closer);
    expression -- highlight the entire expression from opener to closer.
    (For back compatibility, 'default' is a synonym for 'opener').

    Flash-delay is the maximum milliseconds the highlighting remains.
    Any cursor movement (key press or click) before that removes the
    highlight.  If flash-delay is 0, there is no maximum.

    TODO:
    - Augment bell() with mismatch warning in status window.
    - Highlight when cursor is moved to the right of a closer.
      This might be too expensive to check.
    z<<parenmatch-check-restore>>)z
<KeyPress>z
<ButtonPress>z<Key-Return>z<Key-BackSpace>c��||_|j|_|j�|j|j��d|_d|_dS)Nr)�editwin�text�bind�RESTORE_VIRTUAL_EVENT_NAME�
restore_event�counter�is_restore_active)�selfrs  �</usr/local/apps/python3/lib/python3.11/idlelib/parenmatch.py�__init__zParenMatch.__init__(sN������L��	�	����$�9��,�	.�	.�	.����!"�����c��tjdddd���|_tjddddd�	��|_tjddd
dd�	��|_tjtj��d
��|_dS)N�
extensionsr�style�opener)�defaultzflash-delay�inti�)�typer�bell�bool��hilite)r�	GetOption�STYLE�FLASH_DELAY�BELL�GetHighlight�CurrentTheme�
HILITE_CONFIG)�clss r�reloadzParenMatch.reload3s����&���g�x�A�A�A��	�"�,��\�-�e�C�Q�Q�Q����%��\�&�v�q�J�J�J���$�1�(�2G�2I�2I�2:�<�<����rc�z�|js3|jD]"}|j�|j|���#d|_dSdS)z5Activate mechanism to restore text from highlighting.TN)r�RESTORE_SEQUENCESr�	event_addr�r�seqs  r�activate_restorezParenMatch.activate_restore>sW���%�	*��-�
J�
J���	�#�#�D�$C�S�I�I�I�I�%)�D�"�"�"�	*�	*rc�z�|jr3|jD]"}|j�|j|���#d|_dSdS)zRemove restore event bindings.FN)rr0r�event_deleterr2s  r�deactivate_restorezParenMatch.deactivate_restoreEsW���!�	+��-�
M�
M���	�&�&�t�'F��L�L�L�L�%*�D�"�"�"�	+�	+rc�~�t|jd�����}|�|��dS)zAHandle editor 'show surrounding parens' event (menu or shortcut).�insert�break)rr�get_surrounding_brackets�finish_paren_event)r�event�indicess   r�flash_paren_eventzParenMatch.flash_paren_eventLs;���t�|�X�6�6�,�,�.�.�	�����(�(�(��wrc��|j�d��}|tvrdSt|jd��}|���sdS|�t|d��}|�|��dS)zHandle user input of closer.z	insert-1cNT)r�get�_openersrr�
is_in_coder;r<)rr=�closer�hpr>s     r�paren_closed_eventzParenMatch.paren_closed_eventSs�������{�+�+����!�!��F�
���{�
3�
3���}�}���	��F��-�-�h�v�.>��E�E������(�(�(��rc��|�"|jr|j���dS|���|j�|j|j��||��|jr|j	n|j
��dS�N)r)rr"r4�tagfuncsrAr'�create_tag_expressionr(�set_timeout_last�set_timeout_none�rr>s  rr<zParenMatch.finish_paren_event`s����?�t�y�?��I�N�N�����F�������A��
���$�*�d�&@�A�A�$��P�P�P�
2�$�"2�
2��	�	� �1�	5�	5�	5�	5�	5rNc��|j�d��|���|xjdz
c_dS)zRemove effect of doing match.�parenr$N)r�
tag_deleter7r)rr=s  rrzParenMatch.restore_eventks>���	���W�%�%�%����!�!�!���������rc�H�||jkr|���dSdSrH)rr)r�timer_counts  r�handle_restore_timerzParenMatch.handle_restore_timerqs/���$�,�&�&���� � � � � �'�&rc��|j�d|d��|j�d|j��dS)z'Highlight the single paren that matchesrOrN)r�tag_add�
tag_configr,rMs  r�create_tag_openerzParenMatch.create_tag_openerxs?���	���'�7�1�:�.�.�.��	���W�d�&8�9�9�9�9�9rc��|j�|d��dvr|ddz}n|d}|j�d|d|ddz|dz|��|j�d|j��dS)z#Highlight the left and right parensr$r�+1crOrz-1cN�rrArUrVr,�rr>�
rightindexs   r�create_tag_parenszParenMatch.create_tag_parens}s����9�=�=����$�$��7�7� ���E�)�J�J� ���J��	���'�7�1�:�w�q�z�%�/?��E�AQ�S]�^�^�^��	���W�d�&8�9�9�9�9�9rc��|j�|d��dvr|ddz}n|d}|j�d|d|��|j�d|j��dS)zHighlight the entire expressionr$rrYrOrNrZr[s   rrJz ParenMatch.create_tag_expression�sw���9�=�=����$�$��7�7� ���E�)�J�J� ���J��	���'�7�1�:�z�:�:�:��	���W�d�&8�9�9�9�9�9r)rr�parens�
expressionc��|xjdz
c_||j|j�d��fd�}|jj�t||��dS)zSHighlight will remain until user input turns it off
        or the insert has movedr$r9c��||j�d��kr|�|��dS|jj�t||��dS)Nr9)r�indexrSr�
text_frame�after�CHECK_DELAY)�callmer�crcs    rrgz+ParenMatch.set_timeout_none.<locals>.callme�sX����	����1�1�1�1��)�)�!�,�,�,�,�,���'�-�-�k�6�6�J�J�J�J�JrN)rrrcrrdrerf)rrgs  rrLzParenMatch.set_timeout_none�si��	
������� $��������2�2�	K�	K�	K�	K�	
���%�%�k�6�6�B�B�B�B�Brc��|xjdz
c_|jj�|j||jfd���dS)zFThe last highlight created will be removed after FLASH_DELAY millisecsr$c�,�|�|��SrH)rS)rrhs  r�<lambda>z-ParenMatch.set_timeout_last.<locals>.<lambda>�s��d�.G�.G��.J�.J�rN)rrrdrer()rs rrKzParenMatch.set_timeout_last�sV��	
����������%�%������J�J�J�	L�	L�	L�	L�	LrrH)�__name__�
__module__�__qualname__�__doc__rr0r�classmethodr.r4r7r?rFr<rrSrWr]rJrIrLrK�rrrr
s4��������("@��<��	#�	#�	#��<�<��[�<�*�*�*�+�+�+�������	5�	5�	5�����!�!�!�:�:�:�
:�:�:�:�:�:�$�$�#�+�	
�
�H�
C�
C�
C�L�L�L�L�Lrr�__main__)�mainz!idlelib.idle_test.test_parenmatch�)�	verbosityN)ro�idlelib.hyperparserr�idlelib.configrrBrfrr.rl�unittestrsrqrr�<module>rys�����,�+�+�+�+�+�#�#�#�#�#�#����$�$����bL�bL�bL�bL�bL�bL�bL�bL�J�������z����������D�	,��:�:�:�:�:�:��r