;ò
�ü?c           @   sb   d  Z  d k Z d k l Z l Z d k l Z d f  d „  ƒ  YZ d „  Z d f  d „  ƒ  YZ d S(	   sæ  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.

WARNING: This extension will fight with the CallTips extension,
because they both are interested in the KeyRelease-parenright event.
We'll have to fix IDLE to do something reasonable when two or more
extensions what to capture the same event.
N(   s   EditorWindows
   index2line(   s   idleConfs
   ParenMatchc           B   sæ   t  Z d  Z g  Z e i d d d d d ƒZ e i d d d d d d d	 ƒZ e i e i	 ƒ  d
 ƒ Z
 e i d d d d d d d ƒZ d „  Z d „  Z d „  Z e d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sÌ  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:
        - fix interaction with CallTips
        - 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.
    s
   extensionss
   ParenMatchs   styles   defaults
   expressions   flash-delays   types   intiô  s   hilites   bells   booli   c         C   sJ   | |  _  | i |  _ t | ƒ |  _ d |  _ t |  _ |  i |  i	 ƒ d  S(   Ni    (
   s   editwins   selfs   texts   LastOpenBracketFinders   finders   counters   Nones   _restores	   set_styles   STYLE(   s   selfs   editwin(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   __init__5   s    			c         C   s_   | |  _ | d j o |  i |  _ |  i |  _ n* | d j o |  i |  _ |  i |  _ n d  S(   Ns   defaults
   expression(	   s   styles   selfs   STYLEs   create_tag_defaults
   create_tags   set_timeout_lasts   set_timeouts   create_tag_expressions   set_timeout_none(   s   selfs   style(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys	   set_style=   s    	c         C   s^   |  i i t | i ƒ ƒ } | t j o |  i ƒ  d  Sn d |  _	 |  i
 | ƒ |  i ƒ  d  S(   Ni   (   s   selfs   finders   finds   keysym_types   events   keysyms   indexs   Nones   warn_mismatcheds   _restores
   create_tags   set_timeout(   s   selfs   events   index(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   flash_open_paren_eventF   s    
	c         C   s+   |  i o |  i i d ƒ t |  _ n d  S(   Ns   paren(   s   selfs   _restores   texts
   tag_deletes   None(   s   selfs   event(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   check_restore_eventO   s    
c         C   s&   | d |  i j o |  i ƒ  n d  S(   Ni   (   s   timer_counts   selfs   counters   check_restore_event(   s   selfs   timer_count(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   handle_restore_timerT   s    c         C   s   |  i o |  i i ƒ  n d  S(   N(   s   selfs   BELLs   texts   bell(   s   self(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   warn_mismatchedX   s    
c         C   s-   |  i i d | ƒ |  i i d |  i ƒ d S(   s'   Highlight the single paren that matchess   parenN(   s   selfs   texts   tag_adds   indexs
   tag_configs   HILITE_CONFIG(   s   selfs   index(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   create_tag_default_   s     c         C   s0   |  i i d | d ƒ |  i i d |  i ƒ d S(   s   Highlight the entire expressions   parens   insertN(   s   selfs   texts   tag_adds   indexs
   tag_configs   HILITE_CONFIG(   s   selfs   index(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   create_tag_expressiond   s     c         C   s   d S(   s3   Highlight will remain until user input turns it offN(    (   s   self(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   set_timeout_nonel   s     c         C   s9   |  i i i |  i |  |  i d „ ƒ |  i d |  _ d S(   s7   The last highlight created will be removed after .5 secc         C   s   |  i | ƒ S(   N(   s   selfs   handle_restore_timers   c(   s   selfs   c(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   <lambda>u   s    i   N(   s   selfs   editwins
   text_frames   afters   FLASH_DELAYs   counter(   s   self(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   set_timeout_lastp   s     (   s   __name__s
   __module__s   __doc__s   menudefss   idleConfs	   GetOptions   STYLEs   FLASH_DELAYs   GetHighlights   CurrentThemes   HILITE_CONFIGs   BELLs   __init__s	   set_styles   flash_open_paren_events   Nones   check_restore_events   handle_restore_timers   warn_mismatcheds   create_tag_defaults   create_tag_expressions   set_timeout_nones   set_timeout_last(    (    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys
   ParenMatch   s&    										c         C   sj   |  d j p
 |  d j o d Sn |  d j p
 |  d j o d Sn |  d j p
 |  d j o d	 Sn d  S(
   Ns
   parenrights   (s   parens   bracketrights   [s   brackets
   bracerights   {s   brace(   s   ks(   s   ks(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   keysym_typey   s    s   LastOpenBracketFinderc           B   sP   t  Z e i Z e i Z e i Z e i Z d „  Z d „  Z d „  Z	 d „  Z
 RS(   Nc         C   s   | |  _  | i |  _ d  S(   N(   s   editwins   selfs   text(   s   selfs   editwin(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   __init__‰   s    	c   	      C   sâ   t  i |  i |  i ƒ } x– |  i D]‹ } t | | d ƒ } | d } |  i i | d ƒ d  d } | i | ƒ | i |  i |  i | ƒ ƒ } | t j	 p
 | d j o Pq" q" W| i | p d ƒ | i ƒ  } | | i f Sd  S(   Ni   s   .0s   insertiÿÿÿÿs   
i    (   s   PyParses   Parsers   selfs   indentwidths   tabwidths   ys   num_context_liness   contexts   maxs   lnos   startats   startatindexs   texts   gets   rawtexts   set_strs   find_good_parse_starts   context_use_ps1s   _build_char_in_string_funcs   bods   Nones   set_los   get_last_open_bracket_poss   is   str(	   s   selfs   lnos   rawtexts   startats   is   contexts   ys   startatindexs   bod(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   _find_offset_in_buf�   s    
 	c   	      C   s­   t  |  i i d ƒ ƒ } |  i | ƒ \ } } | t j p t	 | | ƒ | j o t Sn | | i d ƒ d } | |  } | i d ƒ d } | | } d | | | f Sd S(   s*   Return the location of the last open parens   inserts   
i   s   %d.%dN(   s
   index2lines   selfs   texts   indexs   lnos   _find_offset_in_bufs   is   bufs   Nones   keysym_types   right_keysym_types   counts
   lines_backs	   upto_opens   rfinds   js   offset(	   s   selfs   right_keysym_types
   lines_backs   is   js   lnos   offsets   bufs	   upto_open(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   find    s     $

c         C   s   | |  i i d „ } | Sd  S(   Nc         C   s   | | d |  ƒ Sd  S(   Ns   %dc(   s   iciss
   startindexs   offset(   s   offsets
   startindexs   icis(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   inner¯   s    (   s
   startindexs   selfs   editwins   is_char_in_strings   inner(   s   selfs
   startindexs   inner(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   _build_char_in_string_func®   s    (   s   __name__s
   __module__s   EditorWindows   num_context_liness   indentwidths   tabwidths   context_use_ps1s   __init__s   _find_offset_in_bufs   finds   _build_char_in_string_func(    (    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   LastOpenBracketFinderƒ   s   							(	   s   __doc__s   PyParses   EditorWindows
   index2lines   configHandlers   idleConfs
   ParenMatchs   keysym_types   LastOpenBracketFinder(   s   LastOpenBracketFinders
   index2lines   PyParses   EditorWindows   idleConfs   keysym_types
   ParenMatch(    (    s/   /mit/python/lib/python2.3/idlelib/ParenMatch.pys   ?   s   	h	
