HEX
Server: Apache/2.4.63 (Unix)
System: Linux TOMS-220NAS 4.4.302+ #86009 SMP Wed Nov 26 18:19:17 CST 2025 x86_64
User: flavio87 (1026)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: //proc/25635/root/usr/lib64/python3.8/idlelib/__pycache__/parenmatch.cpython-38.pyc
U

����@sfdZddlmZddlmZdddd�ZdZGd	d
�d
�Ze��e	dkrbddl
mZed
dd�dS)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@s�eZdZdZdZdZdd�Zedd��Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
d"dd�Zdd�Zdd�Zdd�Zdd�Zeeeed�Zdd�Zd d!�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>cCs0||_|j|_|j�|j|j�d|_d|_dS)Nr)�editwin�textZbind�RESTORE_VIRTUAL_EVENT_NAME�
restore_event�counter�is_restore_active)�selfr
�r�=/tmp/_install_python3/usr/lib/python3.8/idlelib/parenmatch.py�__init__(s
�zParenMatch.__init__cCsVtjddddd�|_tjdddddd	�|_tjddd
ddd	�|_t�t��d
�|_dS)N�
extensionsrZstyle�opener)�defaultzflash-delay�inti�)�typer�bell�bool�Zhilite)rZ	GetOption�STYLE�FLASH_DELAY�BELLZGetHighlightZCurrentTheme�
HILITE_CONFIG)�clsrrr�reload3s.���
�zParenMatch.reloadcCs,|js(|jD]}|j�|j|�qd|_dS)z5Activate mechanism to restore text from highlighting.TN)r�RESTORE_SEQUENCESrZ	event_addr�r�seqrrr�activate_restore>s
zParenMatch.activate_restorecCs,|jr(|jD]}|j�|j|�qd|_dS)zRemove restore event bindings.FN)rr%rZevent_deleterr&rrr�deactivate_restoreEs
zParenMatch.deactivate_restorecCst|jd���}|�|�dS)zAHandle editor 'show surrounding parens' event (menu or shortcut).�insert�break)rr
�get_surrounding_brackets�finish_paren_event)r�event�indicesrrr�flash_paren_eventLs
zParenMatch.flash_paren_eventcCsN|j�d�}|tkrdSt|jd�}|��s0dS|�t|d�}|�|�dS)zHandle user input of closer.z	insert-1cNT)r�get�_openersrr
Z
is_in_coder,r-)rr.ZcloserZhpr/rrr�paren_closed_eventSs
zParenMatch.paren_closed_eventcCsT|dkr|jr|j��dS|��|j�|j|j�||�|jrH|j	n|j
�dS�N)r!rrr(�tagfuncsr1r�create_tag_expressionr �set_timeout_last�set_timeout_none�rr/rrrr-`s
�zParenMatch.finish_paren_eventNcCs&|j�d�|��|jd7_dS)zRemove effect of doing match.�parenrN)rZ
tag_deleter)r)rr.rrrrkszParenMatch.restore_eventcCs||jkr|��dSr4)rr)rZtimer_countrrr�handle_restore_timerqs
zParenMatch.handle_restore_timercCs&|j�d|d�|j�d|j�dS)z'Highlight the single paren that matchesr:rN)r�tag_add�
tag_configr"r9rrr�create_tag_openerxszParenMatch.create_tag_openercCsb|j�|d�dkr"|dd}n|d}|j�d|d|dd|d|�|j�d|j�dS)z#Highlight the left and right parensrr�+1cr:rz-1cN�rr1r<r=r"�rr/Z
rightindexrrr�create_tag_parens}s
$zParenMatch.create_tag_parenscCsR|j�|d�dkr"|dd}n|d}|j�d|d|�|j�d|j�dS)zHighlight the entire expressionrrr?r:rNr@rArrrr6�s
z ParenMatch.create_tag_expression)rrZparensZ
expressioncCs>|jd7_||j|j�d�fdd�}|jj�t||�dS)zSHighlight will remain until user input turns it off
        or the insert has movedrr*cSs2||j�d�kr|�|�n|jj�t||�dS)Nr*)r�indexr;r
�
text_frame�after�CHECK_DELAY)�callmer�crCrrrrG�sz+ParenMatch.set_timeout_none.<locals>.callmeN)rrrCr
rDrErF)rrGrrrr8�s

�
zParenMatch.set_timeout_nonecCs0|jd7_|jj�|j||jfdd��dS)zFThe last highlight created will be removed after FLASH_DELAY millisecsrcSs
|�|�Sr4)r;)rrHrrr�<lambda>��z-ParenMatch.set_timeout_last.<locals>.<lambda>N)rr
rDrEr )rrrrr7�s
�zParenMatch.set_timeout_last)N)�__name__�
__module__�__qualname__�__doc__rr%r�classmethodr$r(r)r0r3r-rr;r>rBr6r5r8r7rrrrr
s.



	
�
r�__main__)�mainz!idlelib.idle_test.test_parenmatch�)�	verbosityN)rNZidlelib.hyperparserrZidlelib.configrr2rFrr$rKZunittestrQrrrr�<module>s&