£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>

Yf:                 @   s   d  Z  d d l m Z d d l m Z d d d d d d	 i Z d
 Z Gd d   d  Z e d k r d d l	 Z	 e	 j
 d d d d S)zParenMatch -- An IDLE extension 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               @   sH  e  Z d  Z d Z d d1 g f g Z e j d d  d d d Z e j d d  d	 d
 d d d Z e j	 e j
   d  Z e j d d  d d
 d d d Z d Z d2 Z d d   Z d d   Z d d   Z d d   Z d d   Z d  d!   Z d" d# d$  Z d% d&   Z d' d(   Z d) d*   Z d+ d,   Z d- d.   Z d/ d0   Z d" S)3
ParenMatcha  Highlight matching parentheses

    There are three supported style of paren matching, based loosely
    on the Emacs options.  The style is select based on the
    HILITE_STYLE attribute; it can be changed used the set_style
    method.

    The supported styles are:

    default -- When a right paren is typed, highlight the matching
        left paren for 1/2 sec.

    expression -- When a right paren is typed, highlight the entire
        expression from the left paren to the right paren.

    TODO:
        - extend IDLE with configuration dialog to change options
        - implement rest of Emacs highlight styles (see below)
        - print mismatch warning in IDLE status window

    Note: In Emacs, there are several styles of highlight where the
    matching paren is highlighted whenever the cursor is immediately
    to the right of a right paren.  I don't know how to do that in Tk,
    so I haven't bothered.
    ZeditShow surrounding parens<<flash-paren>>
extensionsstyledefault
expressionzflash-delaytypeinti  Zhilitebellbool   z<<parenmatch-check-restore>>
<KeyPress><ButtonPress><Key-Return><Key-BackSpace>c             C   sT   | |  _  | j |  _ | j j |  j |  j  d |  _ d |  _ |  j |  j  d  S)Nr   )	editwintextZbindRESTORE_VIRTUAL_EVENT_NAMErestore_eventcounteris_restore_active	set_styleSTYLE)selfr    r$   7/opt/alt/python35/lib64/python3.5/idlelib/ParenMatch.py__init__;   s    	
		zParenMatch.__init__c             C   s@   |  j  s< x' |  j D] } |  j j |  j |  q Wd |  _  d  S)NT)r    RESTORE_SEQUENCESr   Z	event_addr   )r#   seqr$   r$   r%   activate_restoreG   s    	zParenMatch.activate_restorec             C   s@   |  j  r< x' |  j D] } |  j j |  j |  q Wd |  _  d  S)NF)r    r'   r   Zevent_deleter   )r#   r(   r$   r$   r%   deactivate_restoreM   s    	zParenMatch.deactivate_restorec             C   sX   | |  _  | d k r0 |  j |  _ |  j |  _ n$ | d k rT |  j |  _ |  j |  _ d  S)Nr   r   )r"   create_tag_default
create_tagset_timeout_lastset_timeoutcreate_tag_expressionset_timeout_none)r#   r   r$   r$   r%   r!   S   s    	zParenMatch.set_stylec             C   sW   t  |  j d  j   } | d  k r2 |  j   d  S|  j   |  j |  |  j   d  S)Ninsert)r   r   get_surrounding_bracketswarn_mismatchedr)   r,   r-   )r#   eventindicesr$   r$   r%   flash_paren_event\   s    

zParenMatch.flash_paren_eventc             C   s   |  j  j d  } | t k r" d  St |  j d  } | j   sD d  S| j t | d  } | d  k rt |  j   d  S|  j   |  j	 |  |  j
   d  S)Nz	insert-1cT)r   get_openersr   r   Z
is_in_coder2   r3   r)   r,   r.   )r#   r4   ZcloserZhpr5   r$   r$   r%   paren_closed_eventf   s    

zParenMatch.paren_closed_eventNc             C   s-   |  j  j d  |  j   |  j d 7_ d  S)Nparenr   )r   Z
tag_deleter*   r   )r#   r4   r$   r$   r%   r   v   s    
zParenMatch.restore_eventc             C   s   | |  j  k r |  j   d  S)N)r   r   )r#   Ztimer_countr$   r$   r%   handle_restore_timer{   s    zParenMatch.handle_restore_timerc             C   s   |  j  r |  j j   d  S)N)BELLr   r   )r#   r$   r$   r%   r3      s    	zParenMatch.warn_mismatchedc             C   s1   |  j  j d | d  |  j  j d |  j  d S)z'Highlight the single paren that matchesr:   r   N)r   tag_add
tag_configHILITE_CONFIG)r#   r5   r$   r$   r%   r+      s    zParenMatch.create_tag_defaultc             C   sk   |  j  j | d  d	 k r- | d d } n
 | d } |  j  j d | d |  |  j  j d |  j  d S)
zHighlight the entire expressionr   r   r   r   z+1cr:   r   N)r   r   r   )r   r7   r=   r>   r?   )r#   r5   Z
rightindexr$   r$   r%   r/      s
    
z ParenMatch.create_tag_expressionc             C   sP   |  j  d 7_  |  |  j  |  j j d  d d  } |  j j j t | |  d S)zSHighlight will remain until user input turns it off
        or the insert has movedr   r1   c             S   sE   | | j  j d  k r( | j |  n | j j j t |  |   d  S)Nr1   )r   indexr;   r   
text_frameafterCHECK_DELAY)callmer#   cr@   r$   r$   r%   rD      s    z+ParenMatch.set_timeout_none.<locals>.callmeN)r   r   r@   r   rA   rB   rC   )r#   rD   r$   r$   r%   r0      s    	zParenMatch.set_timeout_nonec             C   s;   |  j  d 7_  |  j j j |  j |  |  j  d d   d S)z7The last highlight created will be removed after .5 secr   c             S   s   |  j  |  S)N)r;   )r#   rE   r$   r$   r%   <lambda>   s    z-ParenMatch.set_timeout_last.<locals>.<lambda>N)r   r   rA   rB   FLASH_DELAY)r#   r$   r$   r%   r-      s    zParenMatch.set_timeout_last)r   r   )r   r   r   r   )__name__
__module____qualname____doc__Zmenudefsr   Z	GetOptionr"   rG   ZGetHighlightZCurrentThemer?   r<   r   r'   r&   r)   r*   r!   r6   r9   r   r;   r3   r+   r/   r0   r-   r$   r$   r$   r%   r      s4   	 	
r   __main__Nz!idlelib.idle_test.test_parenmatch	verbosity   )rK   Zidlelib.HyperParserr   Zidlelib.configHandlerr   r8   rC   r   rH   Zunittestmainr$   r$   r$   r%   <module>   s   