;
Ρβ"Ic               @   s[   d  Z  d d l m Z d d l m Z i d d 6d d 6d d	 6Z d
 Z Gd   d  Z d S(   uς   ParenMatch -- 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.
i    (   u   HyperParser(   u   idleConfu   (u   )u   [u   ]u   {u   }id   c             B   s  |  Ee  Z d  Z d d$ 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 d% Z d   Z d   Z d   Z d   Z d   Z d   Z d# d  Z d   Z d   Z d   Z d    Z d!   Z d"   Z d# S(&   u€  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.
    u   editu   Show surrounding parensu   <<flash-paren>>u
   extensionsu
   ParenMatchu   styleu   defaultu
   expressionu   flash-delayu   typeu   intiτ  u   hiliteu   bellu   booli   u   <<parenmatch-check-restore>>u
   <KeyPress>u   <ButtonPress>u   <Key-Return>u   <Key-BackSpace>c             C   sT   | |  _  | j |  _ | j j |  j |  j  d |  _ d |  _ |  j |  j  d  S(   Ni    (	   u   editwinu   textu   bindu   RESTORE_VIRTUAL_EVENT_NAMEu   restore_eventu   counteru   is_restore_activeu	   set_styleu   STYLE(   u   selfu   editwin(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   __init__;   s    	
		c             C   sE   |  j  p7 x' |  j D] } |  j j |  j |  q Wd |  _  n d  S(   NT(   u   is_restore_activeu   RESTORE_SEQUENCESu   textu	   event_addu   RESTORE_VIRTUAL_EVENT_NAMEu   True(   u   selfu   seq(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   activate_restoreG   s
    

 c             C   sE   |  j  o7 x' |  j D] } |  j j |  j |  q Wd |  _  n d  S(   NF(   u   is_restore_activeu   RESTORE_SEQUENCESu   textu   event_deleteu   RESTORE_VIRTUAL_EVENT_NAMEu   False(   u   selfu   seq(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   deactivate_restoreM   s
    

 c             C   s_   | |  _  | d k o |  j |  _ |  j |  _ n* | d k o |  j |  _ |  j |  _ n d  S(   Nu   defaultu
   expression(   u   STYLEu   create_tag_defaultu
   create_tagu   set_timeout_lastu   set_timeoutu   create_tag_expressionu   set_timeout_none(   u   selfu   style(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu	   set_styleS   s    	c             C   sY   t  |  j d  j   } | d  k o |  j   d  S|  j   |  j |  |  j   d  S(   Nu   insert(   u   HyperParseru   editwinu   get_surrounding_bracketsu   Noneu   warn_mismatchedu   activate_restoreu
   create_tagu   set_timeout_last(   u   selfu   eventu   indices(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   flash_paren_event\   s    

c             C   s   |  j  j d  } | t k o d  St |  j d  } | j   p d  S| j t | d  } | d  k o |  j	   d  S|  j
   |  j |  |  j   d  S(   Nu	   insert-1cT(   u   textu   getu   _openersu   HyperParseru   editwinu
   is_in_codeu   get_surrounding_bracketsu   Trueu   Noneu   warn_mismatchedu   activate_restoreu
   create_tagu   set_timeout(   u   selfu   eventu   closeru   hpu   indices(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   paren_closed_evente   s    

c             C   s-   |  j  j d  |  j   |  j d 7_ d  S(   Nu   pareni   (   u   textu
   tag_deleteu   deactivate_restoreu   counter(   u   selfu   event(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   restore_eventu   s    
c             C   s"   | |  j  k o |  j   n d  S(   N(   u   counteru   restore_event(   u   selfu   timer_count(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   handle_restore_timerz   s    c             C   s   |  j  o |  j j   n d  S(   N(   u   BELLu   textu   bell(   u   self(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   warn_mismatched~   s    
c             C   s1   |  j  j d | d  |  j  j d |  j  d S(   u'   Highlight the single paren that matchesu   pareni    N(   u   textu   tag_addu
   tag_configu   HILITE_CONFIG(   u   selfu   indices(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   create_tag_default   s    c             C   sm   |  j  j | d  d	 k o | d d } n | d } |  j  j d | d |  |  j  j d |  j  d S(
   u   Highlight the entire expressioni   u   )u   ]u   }u   +1cu   pareni    N(   u   )u   ]u   }(   u   textu   getu   tag_addu
   tag_configu   HILITE_CONFIG(   u   selfu   indicesu
   rightindex(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   create_tag_expression   s
    
c             C   sM   |  j  d 7_  |  |  j  |  j j d  d  } |  j j j t | |  d S(   uS   Highlight will remain until user input turns it off
        or the insert has movedi   u   insertc             S   sG   | | j  j d  k o | j |  n | j j j t |  |   d  S(   Nu   insert(   u   textu   indexu   handle_restore_timeru   editwinu
   text_frameu   afteru   CHECK_DELAY(   u   callmeu   selfu   cu   index(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   callme   s    N(   u   counteru   textu   indexu   editwinu
   text_frameu   afteru   CHECK_DELAY(   u   selfu   callme(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   set_timeout_none   s    	c             C   s8   |  j  d 7_  |  j j j |  j |  |  j  d   d S(   u7   The last highlight created will be removed after .5 seci   c             S   s   |  j  |  S(    (   u   handle_restore_timer(   u   selfu   c(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   <lambda>«   s    N(   u   counteru   editwinu
   text_frameu   afteru   FLASH_DELAY(   u   self(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   set_timeout_last₯   s    N(   u   Show surrounding parensu   <<flash-paren>>(   u
   <KeyPress>u   <ButtonPress>u   <Key-Return>u   <Key-BackSpace>(   u   __name__u
   __module__u   __doc__u   menudefsu   idleConfu	   GetOptionu   STYLEu   FLASH_DELAYu   GetHighlightu   CurrentThemeu   HILITE_CONFIGu   BELLu   RESTORE_VIRTUAL_EVENT_NAMEu   RESTORE_SEQUENCESu   __init__u   activate_restoreu   deactivate_restoreu	   set_styleu   flash_paren_eventu   paren_closed_eventu   Noneu   restore_eventu   handle_restore_timeru   warn_mismatchedu   create_tag_defaultu   create_tag_expressionu   set_timeout_noneu   set_timeout_last(   u
   __locals__(    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu
   ParenMatch   s4   
	 													u
   ParenMatchN(   u   __doc__u   idlelib.HyperParseru   HyperParseru   idlelib.configHandleru   idleConfu   _openersu   CHECK_DELAYu
   ParenMatch(    (    (    u/   /mit/python/lib/python3.0/idlelib/ParenMatch.pyu   <module>   s
   