3
§ f$ ã @ sf d Z ddlmZ ddlmZ ddddœZdZG d d
„ d
ƒZejƒ 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 ZdZdZd%Zdd„ Zed d
„ ƒZdd„ Z d
d„ Z
dd„ Zdd„ Zdd„ 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<>ú
ú
úúc C s0 || _ |j| _|jj| j| jƒ d| _d| _d S )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__c C sV t jddddd�| _t jdddddd �| _t jddd
ddd �| _t jt jƒ 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 ]}| jj| 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 ]}| jj| 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ƒjƒ }| j|ƒ 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 jdƒ}|tkrdS t| jdƒ}|jƒ s0dS |jt| dƒ}| j|ƒ dS )zHandle user input of closer.z insert-1cNT)r ÚgetÚ_openersr r Z
is_in_coder. r/ )r r0 ZcloserZhpr1 r r r Úparen_closed_eventS s
zParenMatch.paren_closed_eventc C sT |d kr| j r| jjƒ d S | jƒ | jj| j| jƒ| |ƒ | jrH| j n| j
ƒ d S )N)r$ r r r* Útagfuncsr3 r" Úcreate_tag_expressionr# Úset_timeout_lastÚset_timeout_none)r r1 r r r r/ ` s
zParenMatch.finish_paren_eventNc C s&