mò
­fIc           @   sT   d  k  Z  d k Td  k Z d „  Z d f  d „  ƒ  YZ d „  Z d „  Z d „  Z d  S(   N(   t   *c         C   s*   t  |  d ƒ p t |  ƒ |  _ n |  i S(   Nt   _searchengine(   t   hasattrt   roott   SearchEngineR   (   R   (    (    t1   /mit/python/lib/python2.4/idlelib/SearchEngine.pyt   get   s    R   c           B   sž   t  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d d „ Z d „  Z d  d d „ Z d d „ Z d d „ Z RS(   Nc         C   sw   | |  _  t | ƒ |  _ t | ƒ |  _ t | ƒ |  _ t | ƒ |  _ t | ƒ |  _ |  i i	 d ƒ t | ƒ |  _
 d  S(   Ni   (   R   t   selft	   StringVart   patvart
   BooleanVart   revart   casevart   wordvart   wrapvart   sett   backvar(   R   R   (    (    R   t   __init__   s    	c         C   s   |  i i ƒ  S(   N(   R   R	   R   (   R   (    (    R   t   getpat   s    c         C   s   |  i i | ƒ d  S(   N(   R   R	   R   t   pat(   R   R   (    (    R   t   setpat   s    c         C   s   |  i i ƒ  S(   N(   R   R   R   (   R   (    (    R   t   isre!   s    c         C   s   |  i i ƒ  S(   N(   R   R   R   (   R   (    (    R   t   iscase$   s    c         C   s   |  i i ƒ  S(   N(   R   R   R   (   R   (    (    R   t   isword'   s    c         C   s   |  i i ƒ  S(   N(   R   R   R   (   R   (    (    R   t   iswrap*   s    c         C   s   |  i i ƒ  S(   N(   R   R   R   (   R   (    (    R   t   isback-   s    c         C   sK   |  i ƒ  } |  i ƒ  p t i | ƒ } n |  i ƒ  o d | } n | S(   Ns   \b%s\b(   R   R   R   R   t   ret   escapeR   (   R   R   (    (    R   t   getcookedpat2   s    c         C   sÓ   |  i ƒ  } | p |  i | d ƒ d  Sn |  i ƒ  } d } |  i ƒ  p | t i	 B} n y t i
 | | ƒ } Wn[ t i j
 oL } y | \ } } Wn t | ƒ } d } n X|  i | | | ƒ d  Sn X| S(   Ns   Empty regular expressioni    iÿÿÿÿ(   R   R   R   t   report_errort   NoneR   t   flagsR   R   t
   IGNORECASEt   compilet   progt   errort   whatt   msgt   colt   str(   R   R   R$   R   R"   R&   R%   (    (    R   t   getprog:   s&    
	iÿÿÿÿc         C   sq   d t  | ƒ } | o | d t  | ƒ } n | d j o | d t  | ƒ } n t i d | d |  i ƒd  S(   Ns   Error: s   
p\Pattern: i    s	   
Offset: s   Regular expression errort   master(   R'   R%   R   R&   t   tkMessageBoxt	   showerrorR   R   (   R   R   R%   R&   (    (    R   R   O   s    	c         C   s1   |  i ƒ  o t i | ƒ } n |  i | ƒ d  S(   N(   R   R   R   R   R   R   (   R   R   (    (    R   t   setcookedpatY   s    i    c         C   sê   | p |  i ƒ  } | p d Sq& n |  i i ƒ  } t | ƒ \ }
 } |  i ƒ  oK | o
 | } n |
 } t | ƒ \ } }	 |  i | | | |	 | | ƒ } nH | o
 |
 } n | } t | ƒ \ } }	 |  i | | | |	 | | ƒ } | S(   s.  Search a text widget for the pattern.

        If prog is given, it should be the precompiled pattern.
        Return a tuple (lineno, matchobj); None if not found.

        This obeys the wrap and direction (back) settings.

        The search starts at the selection (if there is one) or
        at the insert mark (otherwise).  If the search is forward,
        it starts at the right of the selection; for a backward
        search, it starts at the left end.  An empty match exactly
        at either end of the selection (or at the insert mark if
        there is no selection) is ignored  unless the ok flag is true
        -- this is done to guarantee progress.

        If the search is allowed to wrap around, it will return the
        original selection if (and only if) it is the only match.

        N(   R"   R   R(   R   R   R   t   wrapt   get_selectiont   textt   firstt   lastR   t   okt   startt   get_line_colt   lineR&   t   search_backwardt   rest   search_forward(   R   R/   R"   R2   R3   R-   R7   R1   R5   R&   R0   (    (    R   t   search_text^   s&     
"
c         C   s
  d }	 | } | i d | d | d ƒ }
 xÙ |
 oÑ | i |
 d  | ƒ } | o, | p | i ƒ  | j o | | f Sq} n | d } |	 o | | j o Pn d } d } | i d | d | d ƒ }
 |
 o/ | o( d }	 d } d } | i d d ƒ }
 q- q- Wd  S(   Ni    s   %d.0i   iÿÿÿÿs   1.0s   2.0(   t   wrappedR5   t	   startlineR/   R   t   charsR"   t   searchR&   t   mR2   t   endR-   R   (   R   R/   R"   R5   R&   R-   R2   R;   R>   R:   R<   (    (    R   R8   ˆ   s*     
c         C   s,  d }
 | } | i d | d | d ƒ } xû t | | d  | ƒ } | o, | p | i ƒ  | j  o | | f Sqv n | d } |
 o | | j  o Pn d } | d j oI | p Pn d }
 d } | i d ƒ }	 t t |	 i d ƒ ƒ \ } } n | i d | d | d ƒ } t | ƒ d } q- Wd  S(   Ni    s   %d.0i   iÿÿÿÿs   end-1ct   .(   R:   R5   R;   R/   R   R<   t   search_reverseR"   R&   R>   R2   R3   R-   t   indext   post   mapt   intt   splitt   lenR   (   R   R/   R"   R5   R&   R-   R2   R;   R>   RC   R:   R<   (    (    R   R6   ž   s.      
"(   t   __name__t
   __module__R   R   R   R   R   R   R   R   R   R(   R   R,   R   R9   R8   R6   (    (    (    R   R      s   										
	*c         C   s­   |  i | ƒ } | p d  Sn d  } | i ƒ  \ } } xp | | j  ob | | j oU | } | | j o | d } n |  i | | ƒ } | p Pn | i ƒ  \ } } q9 W| S(   Ni   (
   R"   R=   R<   R>   R   t   foundt   spant   it   jR&   (   R"   R<   R&   RL   RM   R>   RJ   (    (    R   RA   ¹   s     c         C   sw   y" |  i d ƒ } |  i d ƒ } Wn t j
 o d  } } n X| p |  i d ƒ } n | p
 | } n | | f S(   Ns	   sel.firsts   sel.lastt   insert(   R/   RB   R0   R1   t   TclErrorR   (   R/   R1   R0   (    (    R   R.   Ì   s    
c         C   s(   t  t |  i d ƒ ƒ \ } } | | f S(   NR@   (   RD   RE   RB   RF   R5   R&   (   RB   R5   R&   (    (    R   R4   Ú   s    (   R   t   TkinterR*   R   R   RA   R.   R4   (   R.   R   R   R   R*   RA   R4   (    (    R   t   ?   s   			®		