Your IP : 18.191.171.121


Current Path : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/parenmatch.cpython-36.pyc

3

� f$�@sfdZddlmZddlmZdddd�ZdZGd	d
�d
�Zej�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�eZdZdZdZd%Zdd�Zed	d
��Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
d&dd�Zdd�Zdd�Zdd�Zdd�Zeeeed �Zd!d"�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>>�
<KeyPress>�
<ButtonPress>�<Key-Return>�<Key-BackSpace>cCs0||_|j|_|jj|j|j�d|_d|_dS)Nr)�editwin�textZbind�RESTORE_VIRTUAL_EVENT_NAME�
restore_event�counter�is_restore_active)�selfr�r�7/opt/alt/python36/lib64/python3.6/idlelib/parenmatch.py�__init__(s
zParenMatch.__init__cCsVtjddddd�|_tjdddddd	�|_tjddd
ddd	�|_tjtj�d
�|_dS)N�
extensionsrZstyle�opener)�defaultzflash-delay�inti�)�typer�bell�bool�Zhilite)rZ	GetOption�STYLE�FLASH_DELAY�BELLZGetHighlightZCurrentTheme�
HILITE_CONFIG)�clsrrr�reload3s
zParenMatch.reloadcCs0|js,x|jD]}|jj|j|�qWd|_dS)z5Activate mechanism to restore text from highlighting.TN)r�RESTORE_SEQUENCESrZ	event_addr)r�seqrrr�activate_restore>szParenMatch.activate_restorecCs0|jr,x|jD]}|jj|j|�qWd|_dS)zRemove restore event bindings.FN)rr(rZevent_deleter)rr)rrr�deactivate_restoreEszParenMatch.deactivate_restorecCst|jd�j�}|j|�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|jjd�}|tkrdSt|jd�}|j�s0dS|jt|d�}|j|�dS)zHandle user input of closer.z	insert-1cNT)r�get�_openersrrZ
is_in_coder.r/)rr0ZcloserZhpr1rrr�paren_closed_eventSs
zParenMatch.paren_closed_eventcCsT|dkr|jr|jj�dS|j�|jj|j|j�||�|jrH|j	n|j
�dS)N)r$rrr*�tagfuncsr3r"�create_tag_expressionr#�set_timeout_last�set_timeout_none)rr1rrrr/`s
zParenMatch.finish_paren_eventNcCs&|jjd�|j�|jd7_dS)zRemove effect of doing match.�parenr!N)rZ
tag_deleter+r)rr0rrrrkszParenMatch.restore_eventcCs||jkr|j�dS)N)rr)rZtimer_countrrr�handle_restore_timerqs
zParenMatch.handle_restore_timercCs&|jjd|d�|jjd|j�dS)z'Highlight the single paren that matchesr:rN)r�tag_add�
tag_configr%)rr1rrr�create_tag_openerxszParenMatch.create_tag_openercCsb|jj|d�d
kr"|dd}n|d}|jjd|d|dd|d|�|jjd|j�d	S)z#Highlight the left and right parensr!rrr	z+1cr:rz-1cN)rrr	)rr3r<r=r%)rr1�
rightindexrrr�create_tag_parens}s
$zParenMatch.create_tag_parenscCsR|jj|d�d	kr"|dd}n|d}|jjd|d|�|jjd|j�dS)
zHighlight the entire expressionr!rrr	z+1cr:rN)rrr	)rr3r<r=r%)rr1r?rrrr7�s
z ParenMatch.create_tag_expression)rrZparensZ
expressioncCs>|jd7_||j|jjd�fdd�}|jjjt||�dS)zSHighlight will remain until user input turns it off
        or the insert has movedr!r,cSs2||jjd�kr|j|�n|jjjt||�dS)Nr,)r�indexr;r�
text_frame�after�CHECK_DELAY)�callmer�crArrrrE�sz+ParenMatch.set_timeout_none.<locals>.callmeN)rrrArrBrCrD)rrErrrr9�szParenMatch.set_timeout_nonecCs0|jd7_|jjj|j||jfdd��dS)zFThe last highlight created will be removed after FLASH_DELAY millisecsr!cSs
|j|�S)N)r;)rrFrrr�<lambda>�sz-ParenMatch.set_timeout_last.<locals>.<lambda>N)rrrBrCr#)rrrrr8�szParenMatch.set_timeout_last)rr
rr)N)�__name__�
__module__�__qualname__�__doc__rr(r�classmethodr'r*r+r2r5r/rr;r>r@r7r6r9r8rrrrr
s,

	
r�__main__)�mainz!idlelib.idle_test.test_parenmatch�)�	verbosityN)rKZidlelib.hyperparserrZidlelib.configrr4rDrr'rHZunittestrNrrrr�<module>s&

?>