Ñò
—à"Ic           @   sy   d  Z  d d k Td d k l Z d d k Z d Z d Z d Z d Z d Z	 d Z
 d Z d Z d Z d d d „  ƒ  YZ d S(   sH   
An auto-completion window for IDLE, used by the AutoComplete extension
iÿÿÿÿ(   t   *(   t   MC_SHIFTNs   <<autocompletewindow-hide>>s
   <FocusOut>s   <ButtonPress>s   <<autocompletewindow-keypress>>s   <Key>s   <Key-BackSpace>s   <Key-Return>s	   <Key-Tab>s   <Key-Up>s
   <Key-Down>s
   <Key-Home>s	   <Key-End>s   <Key-Prior>s
   <Key-Next>s!   <<autocompletewindow-keyrelease>>s   <KeyRelease>s   <B1-ButtonRelease>s   <Configure>s   <B1-Double-ButtonRelease>t   AutoCompleteWindowc           B   s   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s¨   | |  _  d  |  _ |  _ |  _ d  |  _ |  _ d  |  _ d  |  _ d  |  _	 d  |  _
 d  |  _ d  |  _ d  |  _ d  |  _ |  _ |  _ |  _ |  _ |  _ t |  _ d  S(   N(   t   widgett   Nonet   autocompletewindowt   listboxt	   scrollbart   origselforegroundt   origselbackgroundt   completionst   morecompletionst   modet   startt
   startindext   lasttypedstartt   userwantswindowt   hideidt
   keypressidt   listupdateidt   winconfigidt   keyreleaseidt   doubleclickidt   Falset   lastkey_was_tab(   t   selfR   (    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyt   __init__   s    								,c         C   só   t  t |  i ƒ t | ƒ ƒ } d } x4 | | j  o& |  i | | | j o | d 7} q' W| t |  i ƒ j  o: |  i i d |  i | f d |  i t |  i ƒ f ƒ n | t | ƒ j  o( |  i i d |  i | f | | ƒ n | |  _ d  S(   Ni    i   s   %s+%dc(   t   mint   lenR   R   t   deleteR   t   insert(   R   t   newstartt   min_lent   i(    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyt   _change_start8   s     %!c         C   sz   d } t  |  i ƒ } xH | | j o: | | d } |  i | | j o
 | } q | d } q Wt | t  |  i ƒ d ƒ S(   s’   Find the first index in self.completions where completions[i] is
        greater or equal to s, or the last index if there is no such
        one.i    i   i   (   R   R
   R   (   R   t   sR!   t   jt   m(    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyt   _binary_searchE   s      
c   
      C   s@  |  i  | ƒ } |  i | t | ƒ  | j o | S| d } t |  i ƒ } xR | | j oD | | d } |  i | t | ƒ  | j o
 | } qN | d } qN W| d } | | j o |  i | S|  i | } |  i | } t t | ƒ t | ƒ ƒ }	 t | ƒ } x1 | |	 j  o# | | | | j o | d 7} qW| |  S(   sÖ   Assuming that s is the prefix of a string in self.completions,
        return the longest string which is a prefix of all the strings which
        s is a prefix of them. If s is not a prefix of a string, return s.i   i   (   R&   R
   R   R   (
   R   R#   t   firstR!   R$   R%   t   lastt
   first_compt	   last_compR    (    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyt   _complete_stringR   s,    
 

 "c         C   sÊ  t  |  i i ƒ  d ƒ } |  i i | ƒ |  i } |  i | } |  i | ƒ | j o
 | } n` t t | ƒ t | ƒ ƒ } d } x1 | | j  o# | | | | j o | d 7} qƒ W| |  } |  i	 | ƒ |  i | t |  i
 ƒ  |  i
 j o# |  i i d |  i d |  i ƒ nµ |  i i d |  i i d ƒ d |  i i d ƒ ƒ |  i oy |  i |  _ d |  _ |  i i d t ƒ x$ |  i D] } |  i i t | ƒ qW|  i i |  i |  i
 ƒ ƒ |  i ƒ  n d S(   s|   Should be called when the selection of the Listbox has changed.
        Updates the Listbox display and calls _change_start.i    i   t   selectbackgroundt   selectforegroundt   bgt   fgN(   t   intR   t   curselectiont   seeR   R
   R&   R   R   R"   R   t	   configureR	   R   t   cgetR   R   R   t   ENDR   t
   select_sett   _selection_changed(   R   t   curselt   ltst   selstartR   R    R!   t   item(    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyR7   q   s6    	
 "
$
	
 c         C   sC  | \ |  _  |  _ | |  _ |  i i | ƒ |  _ |  i i |  i d ƒ |  _ | o‡ |  i |  i ƒ } |  i	 | ƒ |  i
 | ƒ } |  i  | | j oA | t |  i  ƒ d j p" |  i  | d t | ƒ  | j o d Sn | |  _ |  i |  _ t |  i ƒ |  _ } | i d ƒ | i d ƒ y# | i i d d | i d d ƒ Wn t j
 o n Xt | d	 t ƒ|  _ }	 t | d
 |	 i d t d d ƒ|  _ }
 x! |  i  D] } |
 i t | ƒ q¢W|
 i d ƒ |  _  |
 i d ƒ |  _! |	 i" d |
 i# ƒ |	 i$ d t% d t& ƒ |
 i$ d t' d t( d t) ƒ |  i i* |  i
 |  i ƒ ƒ |  i+ ƒ  |  i i, t- |  i. ƒ |  _/ x! t0 D] } |  i i1 t- | ƒ qmW|  i i, t2 |  i3 ƒ |  _4 x! t5 D] } |  i i1 t2 | ƒ q¬W|  i i, t6 |  i7 ƒ |  _8 |  i i1 t6 t9 ƒ |
 i, t: |  i; ƒ |  _< | i, t= |  i> ƒ |  _? |
 i, t@ |  iA ƒ |  _B d S(   s¤   Show the autocomplete list, bind events.
        If complete is True, complete the text, and if there is exactly one
        matching completion, don't open a list.R   i   Ns   +10000+10000s!   ::tk::unsupported::MacWindowStylet   stylet   helpt   noActivatest   orientt   yscrollcommandt   exportselectionR.   t   whiteR-   R,   t   commandt   sidet   fillt   expand(C   R
   R   R   R   t   indexR   t   getR   R+   R"   R&   R   R   R   t   ToplevelR   t   wm_geometryt   wm_overrideredirectt   tkt   callt   _wt   TclErrort	   Scrollbart   VERTICALR   t   Listboxt   setR   R   R   R5   R4   R   R	   t   configt   yviewt   packt   RIGHTt   Yt   LEFTt   BOTHt   TrueR6   R7   t   bindt   HIDE_VIRTUAL_EVENT_NAMEt
   hide_eventR   t   HIDE_SEQUENCESt	   event_addt   KEYPRESS_VIRTUAL_EVENT_NAMEt   keypress_eventR   t   KEYPRESS_SEQUENCESt   KEYRELEASE_VIRTUAL_EVENT_NAMEt   keyrelease_eventR   t   KEYRELEASE_SEQUENCEt   LISTUPDATE_SEQUENCEt   listselect_eventR   t   WINCONFIG_SEQUENCEt   winconfig_eventR   t   DOUBLECLICK_SEQUENCEt   doubleclick_eventR   (   R   t
   comp_listsRG   t   completeR   t   userWantsWint	   completedR!   t   acwR   R   R;   t   seq(    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyt   show_window•   sj    	"		
 
  		c         C   s  |  i  ƒ  p d  S|  i } | i |  i ƒ | i |  i ƒ \ } } } } |  i } | i ƒ  | i ƒ  } }	 | i ƒ  | i ƒ  }
 } | i ƒ  t	 | t
 d |
 | ƒ ƒ } | i ƒ  | } | | | |	 j p | |	 j  o | | 7} n | |	 8} | i d | | f ƒ d  S(   Ni    s   +%d+%d(   t	   is_activeR   R2   R   t   bboxR   t   winfo_widtht   winfo_heightt   winfo_rootxR   t   maxt   winfo_rootyRJ   (   R   t   eventt   textt   xt   yt   cxt   cyRq   t	   acw_widtht
   acw_heightt
   text_widtht   text_heightt   new_xt   new_y(    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyRj   Ù   s    		&
c         C   s    |  i  ƒ  p d  S|  i ƒ  d  S(   N(   Rt   t   hide_window(   R   R{   (    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyR^   î   s    c         C   sL   |  i  ƒ  p d  St |  _ t |  i i ƒ  d ƒ } |  i |  i | ƒ d  S(   Ni    (   Rt   R[   R   R0   R   R1   R"   R
   (   R   R{   R8   (    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyRh   ó   s
    	c         C   s;   t  |  i i ƒ  d ƒ } |  i |  i | ƒ |  i ƒ  d  S(   Ni    (   R0   R   R1   R"   R
   R‡   (   R   R{   R8   (    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyRl   ú   s    c   	   	   C   s)  |  i  ƒ  p d  S| i } t | d ƒ o | i } n d } | d j o t |  _ n t | ƒ d j p- | d% j p  |  i t i	 j o | d& j o=| t
 @o0t | ƒ d j o |  i |  i | ƒ n© | d j o |  i |  i d	 ƒ n„ | d j o |  i |  i d
 ƒ n_ | d j o |  i |  i d ƒ n: t |  i ƒ d j o |  i ƒ  d  S|  i |  i d  ƒ |  i |  _ |  i i d t |  i i ƒ  d ƒ ƒ |  i i |  i |  i ƒ ƒ |  i ƒ  d S| d j o |  i ƒ  d  S|  i t i j o | d' j p- |  i t i	 j o | d( j oŽ | t
 @o t |  i i ƒ  d ƒ } |  i | t |  i ƒ  |  i j o5 |  i t i j p
 |  i o |  i |  i | ƒ n |  i ƒ  d  S| d) j o”| oŒt |  _ t |  i i ƒ  d ƒ } | d j o
 d } n| d j o t |  i ƒ d } ní | d* j o‡ |  i i |  i i ƒ  ƒ |  i i d ƒ } | d j o t d | | ƒ } q| d j p t ‚ t t |  i ƒ d | | ƒ } nY | d j o t d | d ƒ } n5 | d j p t ‚ t t |  i ƒ d | d ƒ } |  i i | ƒ |  i i | ƒ |  i ƒ  |  i |  i | ƒ d S| d j oh | o` |  i o< t |  i i ƒ  d ƒ } |  i |  i | ƒ |  i ƒ  d St |  _ t |  _ d  SnQ t d „  g  } d+ D] } | | i  | ƒ d j qé~ ƒ o d  S|  i ƒ  d  Sd  S(,   Nt   mc_statei    t   Tabi   t
   underscoret	   BackSpacet   periodt   minust   _t   .t   -iÿÿÿÿt   breakt   Returnt   spacet	   parenleftt
   parenrightt   bracketleftt   bracketrightt   slasht	   backslasht   quotedblt
   apostrophet   Homet   Endt   Priort   Nextt   Upt   Downc         S   s   |  p | S(    (    (   R}   R~   (    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyt   <lambda>`  s    t   Shiftt   Controlt   Altt   Metat   Commandt   Option(   RŠ   R‹   (   RŒ   R   (   RŒ   R“   R”   R•   R–   R—   (   R˜   R™   Rš   R›   (   Rœ   R   Rž   RŸ   R    R¡   (   Rž   RŸ   (   R£   R¤   R¥   R¦   R§   R¨   (!   Rt   t   keysymt   hasattrRˆ   R   R   R   R   t   AutoCompletet   COMPLETE_FILESR   R"   R   R‡   R   R   t   select_clearR0   R1   R6   R&   R7   t   COMPLETE_ATTRIBUTESR
   R[   R   t   nearestRw   Ry   t   AssertionErrorR   t   reducet   find(	   R   R{   R©   t   stateR8   t   newselt   jumpt   _[1]R#   (    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyRb      s¦    	 

&

 

$
	
$ 


			-
c         C   s_   |  i  ƒ  p d  S|  i i d ƒ |  i i d |  i t |  i ƒ f ƒ j o |  i ƒ  n d  S(   NR   s   %s+%dc(   Rt   R   RG   R   R   R   R‡   (   R   R{   (    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyRe   l  s
    ,c         C   s   |  i  d  j	 S(   N(   R   R   (   R   (    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyRt   t  s    c         C   s   |  i  |  i |  i ƒ ƒ d  S(   N(   R"   R+   R   (   R   (    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyRn   w  s    c         C   sN  |  i  ƒ  p d  Sx! t D] } |  i i t | ƒ q W|  i i t |  i ƒ d  |  _ x! t D] } |  i i t	 | ƒ q\ W|  i i t	 |  i
 ƒ d  |  _
 |  i i t t ƒ |  i i t |  i ƒ d  |  _ |  i i t |  i ƒ d  |  _ |  i i t |  i ƒ d  |  _ |  i i ƒ  d  |  _ |  i i ƒ  d  |  _ |  i i ƒ  d  |  _ d  S(   N(   Rt   R_   R   t   event_deleteR]   t   unbindR   R   Rc   Ra   R   Rd   Rf   R   R   Rg   R   R   Ri   R   R   t   destroy(   R   Rr   (    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyR‡   {  s4     	 						(   t   __name__t
   __module__R   R"   R&   R+   R7   Rs   Rj   R^   Rh   Rl   Rb   Re   Rt   Rn   R‡   (    (    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyR      s   	 				$	D					l			(   s
   <FocusOut>s   <ButtonPress>(
   s   <Key>s   <Key-BackSpace>s   <Key-Return>s	   <Key-Tab>s   <Key-Up>s
   <Key-Down>s
   <Key-Home>s	   <Key-End>s   <Key-Prior>s
   <Key-Next>(    (   t   __doc__t   Tkintert	   MultiCallR   R«   R]   R_   Ra   Rc   Rd   Rf   Rg   Ri   Rk   R   (    (    (    s7   /mit/python/lib/python2.6/idlelib/AutoCompleteWindow.pyt   <module>   s   
  