OwlCyberSecurity - MANAGER
Edit File: parenmatch.cpython-37.pyc
B ����� f$������������������@���sf���d�Z�ddlmZ�ddlmZ�dddd�ZdZG�d d ��d �Ze����e dkrbddl mZ�ed 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�(�[�{)�)�]�}�d���c���������������@���s����e�Zd�ZdZdZdZdd��Zedd���Zdd ��Z d d��Z dd ��Zdd��Zdd��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>c�������������C���s0���||�_�|j|�_|j�|�j|�j��d|�_d|�_d�S�)Nr���)�editwin�textZbind�RESTORE_VIRTUAL_EVENT_NAME� restore_event�counter�is_restore_active)�selfr�����r����7/opt/alt/python37/lib64/python3.7/idlelib/parenmatch.py�__init__(���s���� zParenMatch.__init__c�������������C���sV���t�jddddd�|�_t�jdddddd �|�_t�jddd ddd �|�_t��t����d �|�_d�S�)N� extensionsr���Zstyle�opener)�defaultzflash-delay�inti���)�typer����bell�bool����Zhilite)r���Z GetOption�STYLE�FLASH_DELAY�BELLZGetHighlightZCurrentTheme� HILITE_CONFIG)�clsr���r���r����reload3���s���� zParenMatch.reloadc�������������C���s0���|�j�s,x|�jD�]}|�j�|�j|��qW�d|�_�dS�)z5Activate mechanism to restore text from highlighting.TN)r����RESTORE_SEQUENCESr ���Z event_addr���)r����seqr���r���r����activate_restore>���s����zParenMatch.activate_restorec�������������C���s0���|�j�r,x|�jD�]}|�j�|�j|��qW�d|�_�dS�)zRemove restore event bindings.FN)r���r$���r ���Zevent_deleter���)r���r%���r���r���r����deactivate_restoreE���s����zParenMatch.deactivate_restorec�������������C���s���t�|�jd����}|��|��dS�)zAHandle editor 'show surrounding parens' event (menu or shortcut).�insert�break)r���r����get_surrounding_brackets�finish_paren_event)r����event�indicesr���r���r����flash_paren_eventL���s���� zParenMatch.flash_paren_eventc�������������C���sN���|�j��d�}|tkrdS�t|�jd�}|���s0dS�|�t|�d�}|��|��dS�)zHandle user input of closer.z insert-1cNT)r ����get�_openersr���r���Z is_in_coder*���r+���)r���r,���ZcloserZhpr-���r���r���r����paren_closed_eventS���s���� zParenMatch.paren_closed_eventc�������������C���sT���|d�kr|�j�r|�j����d�S�|�����|�j�|�j|�j�|�|��|�jrH|�j n|�j ���d�S�)N)r ���r ���r���r&����tagfuncsr/���r����create_tag_expressionr����set_timeout_last�set_timeout_none)r���r-���r���r���r���r+���`���s���� zParenMatch.finish_paren_eventNc�������������C���s&���|�j��d��|�����|��jd7��_dS�)zRemove effect of doing match.�parenr���N)r ���Z tag_deleter'���r���)r���r,���r���r���r���r���k���s����zParenMatch.restore_eventc�������������C���s���||�j�kr|�����d�S�)N)r���r���)r���Ztimer_countr���r���r����handle_restore_timerq���s���� zParenMatch.handle_restore_timerc�������������C���s&���|�j��d|d���|�j��d|�j��dS�)z'Highlight the single paren that matchesr6���r���N)r ����tag_add� tag_configr!���)r���r-���r���r���r����create_tag_openerx���s����zParenMatch.create_tag_openerc�������������C���sb���|�j��|d��dkr"|d�d�}n|d�}|�j��d|d�|d�d�|d�|��|�j��d|�j��dS�)z#Highlight the left and right parensr���)r���r���r ���z+1cr6���r���z-1cN)r ���r/���r8���r9���r!���)r���r-���� rightindexr���r���r����create_tag_parens}���s ����$zParenMatch.create_tag_parensc�������������C���sR���|�j��|d��dkr"|d�d�}n|d�}|�j��d|d�|��|�j��d|�j��dS�)zHighlight the entire expressionr���)r���r���r ���z+1cr6���r���N)r ���r/���r8���r9���r!���)r���r-���r;���r���r���r���r3�������s ����z ParenMatch.create_tag_expression)r���r���ZparensZ expressionc�������������C���s>���|��j�d7��_�|�|�j�|�j�d�fdd�}|�jj�t||��dS�)zSHighlight will remain until user input turns it off or the insert has movedr���r(���c�������������S���s2���||j��d�kr|�|��n|jj�t|�|���d�S�)Nr(���)r ����indexr7���r���� text_frame�after�CHECK_DELAY)�callmer����cr=���r���r���r���rA�������s����z+ParenMatch.set_timeout_none.<locals>.callmeN)r���r ���r=���r���r>���r?���r@���)r���rA���r���r���r���r5�������s����zParenMatch.set_timeout_nonec�������������C���s0���|��j�d7��_�|�jj�|�j|�|�j�fdd���dS�)zFThe last highlight created will be removed after FLASH_DELAY millisecsr���c�������������S���s ���|���|�S�)N)r7���)r���rB���r���r���r����<lambda>���������z-ParenMatch.set_timeout_last.<locals>.<lambda>N)r���r���r>���r?���r���)r���r���r���r���r4�������s����zParenMatch.set_timeout_last)N)�__name__� __module__�__qualname__�__doc__r���r$���r����classmethodr#���r&���r'���r.���r1���r+���r���r7���r:���r<���r3���r2���r5���r4���r���r���r���r���r��� ���s*��� r����__main__)�mainz!idlelib.idle_test.test_parenmatch����)� verbosityN)rH���Zidlelib.hyperparserr���Zidlelib.configr���r0���r@���r���r#���rE���ZunittestrK���r���r���r���r����<module>���s����&