;
Ðâ"Ic               @   s€   d  Z  d d l Td d l m Z d d l m Z m Z d Z d Z d Z	 d Z
 d Z d Z d Z d Z d Z Gd „  d ƒ Z d S(   uH   
An auto-completion window for IDLE, used by the AutoComplete extension
i    (   u   *(   u   MC_SHIFT(   u   COMPLETE_FILESu   COMPLETE_ATTRIBUTESu   <<autocompletewindow-hide>>u
   <FocusOut>u   <ButtonPress>u   <<autocompletewindow-keypress>>u   <Key>u   <Key-BackSpace>u   <Key-Return>u	   <Key-Tab>u   <Key-Up>u
   <Key-Down>u
   <Key-Home>u	   <Key-End>u   <Key-Prior>u
   <Key-Next>u!   <<autocompletewindow-keyrelease>>u   <KeyRelease>u   <B1-ButtonRelease>u   <Configure>u   <B1-Double-ButtonRelease>c             B   s•   |  Ee  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 d S(   c             C   s¨   | |  _  d  |  _ |  _ |  _ d  |  _ |  _ d  |  _ d  |  _ d  |  _	 d  |  _
 d  |  _ d  |  _ d  |  _ d  |  _ |  _ |  _ |  _ |  _ |  _ d |  _ d  S(   NF(   u   widgetu   Noneu   autocompletewindowu   listboxu	   scrollbaru   origselforegroundu   origselbackgroundu   completionsu   morecompletionsu   modeu   startu
   startindexu   lasttypedstartu   userwantswindowu   hideidu
   keypressidu   listupdateidu   winconfigidu   keyreleaseidu   doubleclickidu   Falseu   lastkey_was_tab(   u   selfu   widget(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   __init__   s    								,c             C   sù   t  t |  j ƒ t | ƒ ƒ } d } x4 | | k  o& |  j | | | k o | d 7} q' W| t |  j ƒ k  o: |  j j d |  j | f d |  j t |  j ƒ f ƒ n | t | ƒ k  o. |  j j d |  j | f | | d  … ƒ n | |  _ d  S(   Ni    i   u   %s+%dc(   u   minu   lenu   startu   widgetu   deleteu
   startindexu   insert(   u   selfu   newstartu   min_lenu   i(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   _change_start8   s     %!c             C   sz   d } t  |  j ƒ } xH | | k o: | | d } |  j | | k o
 | } q | d } q Wt | t  |  j ƒ d ƒ S(   u’   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   (   u   lenu   completionsu   min(   u   selfu   su   iu   ju   m(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   _binary_searchE   s      
c       
      C   sR  |  j  | ƒ } |  j | d t | ƒ … | k o | S| d } t |  j ƒ } xX | | k oJ | | d } |  j | d t | ƒ … | k o
 | } qT | d } qT W| d } | | k o |  j | S|  j | } |  j | } t t | ƒ t | ƒ ƒ }	 t | ƒ } x1 | |	 k  o# | | | | k o | d 7} qW| d | … S(   uÖ   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.Ni   i   (   u   _binary_searchu   completionsu   lenu   min(
   u   selfu   su   firstu   iu   ju   mu   lastu
   first_compu	   last_compu   min_len(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   _complete_stringR   s,    $
 $

 "c             C   sÖ  t  |  j j ƒ  d ƒ } |  j j | ƒ |  j } |  j | } |  j | ƒ | k o
 | } nf t t | ƒ t | ƒ ƒ } d } x1 | | k  o# | | | | k o | d 7} qƒ W| d | … } |  j	 | ƒ |  j | d t |  j
 ƒ … |  j
 k o# |  j j d |  j d |  j ƒ nµ |  j j d |  j j d ƒ d |  j j d ƒ ƒ |  j oy |  j |  _ d |  _ |  j j d t ƒ x$ |  j D] } |  j j t | ƒ q‹W|  j j |  j |  j
 ƒ ƒ |  j ƒ  n d S(   u|   Should be called when the selection of the Listbox has changed.
        Updates the Listbox display and calls _change_start.i    i   Nu   selectbackgroundu   selectforegroundu   bgu   fg(   u   intu   listboxu   curselectionu   seeu   lasttypedstartu   completionsu   _binary_searchu   minu   lenu   _change_startu   startu	   configureu   origselbackgroundu   origselforegroundu   cgetu   morecompletionsu   Noneu   deleteu   ENDu   insertu
   select_setu   _selection_changed(   u   selfu   curselu   ltsu   selstartu   newstartu   min_lenu   iu   item(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   _selection_changedq   s6    	
 "*
	
 c             C   sJ  | \ |  _  |  _ | |  _ |  j j | ƒ |  _ |  j j |  j d ƒ |  _ | o |  j |  j ƒ } |  j	 | ƒ |  j
 | ƒ } |  j  | | k oG | t |  j  ƒ d k p( |  j  | d d t | ƒ … | k o d Sn | |  _ |  j |  _ t |  j ƒ |  _ } | j d ƒ | j d ƒ y# | j j d d | j d d ƒ Wn t k
 o Yn Xt | d	 t ƒ|  _ }	 t | d
 |	 j d d d d ƒ|  _ }
 x! |  j  D] } |
 j t | ƒ q©W|
 j d ƒ |  _  |
 j d ƒ |  _! |	 j" d |
 j# ƒ |	 j$ d t% d t& ƒ |
 j$ d t' d t( d d ƒ |  j j* |  j
 |  j ƒ ƒ |  j+ ƒ  |  j j, t- |  j. ƒ |  _/ x! t0 D] } |  j j1 t- | ƒ qtW|  j j, t2 |  j3 ƒ |  _4 x! t5 D] } |  j j1 t2 | ƒ q³W|  j j, t6 |  j7 ƒ |  _8 |  j j1 t6 t9 ƒ |
 j, t: |  j; ƒ |  _< | j, t= |  j> ƒ |  _? |
 j, t@ |  jA ƒ |  _B d S(   u¤   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.u   inserti   Nu   +10000+10000u!   ::tk::unsupported::MacWindowStyleu   styleu   helpu   noActivatesu   orientu   yscrollcommandu   exportselectionu   bgu   whiteu   selectforegroundu   selectbackgroundu   commandu   sideu   fillu   expandFT(C   u   completionsu   morecompletionsu   modeu   widgetu   indexu
   startindexu   getu   startu   _complete_stringu   _change_startu   _binary_searchu   lenu   userwantswindowu   lasttypedstartu   Toplevelu   autocompletewindowu   wm_geometryu   wm_overrideredirectu   tku   callu   _wu   TclErroru	   Scrollbaru   VERTICALu	   scrollbaru   Listboxu   setu   Falseu   listboxu   insertu   ENDu   cgetu   origselforegroundu   origselbackgroundu   configu   yviewu   packu   RIGHTu   Yu   LEFTu   BOTHu   Trueu
   select_setu   _selection_changedu   bindu   HIDE_VIRTUAL_EVENT_NAMEu
   hide_eventu   hideidu   HIDE_SEQUENCESu	   event_addu   KEYPRESS_VIRTUAL_EVENT_NAMEu   keypress_eventu
   keypressidu   KEYPRESS_SEQUENCESu   KEYRELEASE_VIRTUAL_EVENT_NAMEu   keyrelease_eventu   keyreleaseidu   KEYRELEASE_SEQUENCEu   LISTUPDATE_SEQUENCEu   listselect_eventu   listupdateidu   WINCONFIG_SEQUENCEu   winconfig_eventu   winconfigidu   DOUBLECLICK_SEQUENCEu   doubleclick_eventu   doubleclickid(   u   selfu
   comp_listsu   indexu   completeu   modeu   userWantsWinu	   completedu   iu   acwu	   scrollbaru   listboxu   itemu   seq(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   show_window•   sj    	(		
 
  		c             C   s  |  j  ƒ  p d  S|  j } | j |  j ƒ | j |  j ƒ \ } } } } |  j } | j ƒ  | j ƒ  } }	 | j ƒ  | j ƒ  }
 } | j ƒ  t	 | t
 d |
 | ƒ ƒ } | j ƒ  | } | | | |	 k p | |	 k  o | | 7} n | |	 8} | j d | | f ƒ d  S(   Ni    u   +%d+%d(   u	   is_activeu   widgetu   seeu
   startindexu   bboxu   autocompletewindowu   winfo_widthu   winfo_heightu   winfo_rootxu   minu   maxu   winfo_rootyu   wm_geometry(   u   selfu   eventu   textu   xu   yu   cxu   cyu   acwu	   acw_widthu
   acw_heightu
   text_widthu   text_heightu   new_xu   new_y(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   winconfig_eventÙ   s    		&
c             C   s    |  j  ƒ  p d  S|  j ƒ  d  S(   N(   u	   is_activeu   hide_window(   u   selfu   event(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu
   hide_eventî   s    c             C   sL   |  j  ƒ  p d  Sd |  _ t |  j j ƒ  d ƒ } |  j |  j | ƒ d  S(   Ni    T(   u	   is_activeu   Trueu   userwantswindowu   intu   listboxu   curselectionu   _change_startu   completions(   u   selfu   eventu   cursel(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   listselect_eventó   s
    	c             C   s;   t  |  j j ƒ  d ƒ } |  j |  j | ƒ |  j ƒ  d  S(   Ni    (   u   intu   listboxu   curselectionu   _change_startu   completionsu   hide_window(   u   selfu   eventu   cursel(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   doubleclick_eventú   s    c                sá  |  j  ƒ  p d  S| j ‰  t | d ƒ o | j } n d } ˆ  d k o d% |  _ n t ˆ  ƒ d k p* ˆ  d& k p |  j t k o ˆ  d' k oC| t	 @o6t ˆ  ƒ d k o |  j
 |  j ˆ  ƒ n¯ ˆ  d k o |  j
 |  j d	 ƒ nŠ ˆ  d k o |  j
 |  j d
 ƒ ne ˆ  d k o |  j
 |  j d ƒ n@ t |  j ƒ d k o |  j ƒ  d  S|  j
 |  j d  d … ƒ |  j |  _ |  j j d t |  j j ƒ  d ƒ ƒ |  j j |  j |  j ƒ ƒ |  j ƒ  d Sˆ  d k o |  j ƒ  d  S|  j t k o ˆ  d( k p* |  j t k o ˆ  d) k o‘ | t	 @o„ t |  j j ƒ  d ƒ } |  j | d  t |  j ƒ … |  j k o2 |  j t k p
 |  j o |  j
 |  j | ƒ n |  j ƒ  d  Sˆ  d* k ol| odd+ |  _ t |  j j ƒ  d ƒ } ˆ  d k o
 d } né ˆ  d k o t |  j ƒ d } nÅ ˆ  d, k os |  j j |  j j ƒ  ƒ |  j j d ƒ } ˆ  d k o t d | | ƒ } qõt t |  j ƒ d | | ƒ } nE ˆ  d k o t d | d ƒ } n! t t |  j ƒ d | d ƒ } |  j j | ƒ |  j j | ƒ |  j ƒ  |  j
 |  j | ƒ d Sˆ  d k oh | o` |  j o< t |  j j ƒ  d ƒ } |  j
 |  j | ƒ |  j ƒ  d Sd+ |  _ d+ |  _ d  Sn1 t ‡  f d †  d- Dƒ ƒ o d  S|  j ƒ  d  Sd  S(.   Nu   mc_statei    u   Tabi   u
   underscoreu	   BackSpaceu   periodu   minusu   _u   .u   -iÿÿÿÿu   breaku   Returnu   spaceu	   parenleftu
   parenrightu   bracketleftu   bracketrightu   slashu	   backslashu   quotedblu
   apostropheu   Homeu   Endu   Prioru   Nextu   Upu   Downc             3   s   |  ] } | ˆ  k Vq d  S(   N(    (   u   .0u   s(   u   keysym(    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu	   <genexpr>`  s    u   Shiftu   Controlu   Altu   Metau   Commandu   OptionF(   u
   underscoreu	   BackSpace(   u   periodu   minus(   u   periodu   spaceu	   parenleftu
   parenrightu   bracketleftu   bracketright(   u   slashu	   backslashu   quotedblu
   apostrophe(   u   Homeu   Endu   Prioru   Nextu   Upu   DownT(   u   Prioru   Next(   u   Shiftu   Controlu   Altu   Metau   Commandu   Option(   u	   is_activeu   keysymu   hasattru   mc_stateu   Falseu   lastkey_was_tabu   lenu   modeu   COMPLETE_FILESu   MC_SHIFTu   _change_startu   startu   hide_windowu   lasttypedstartu   listboxu   select_clearu   intu   curselectionu
   select_setu   _binary_searchu   _selection_changedu   COMPLETE_ATTRIBUTESu   completionsu   Trueu   userwantswindowu   nearestu   winfo_heightu   maxu   minu   any(   u   selfu   eventu   stateu   curselu   newselu   jump(    (   u   keysymu7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   keypress_event   s     	 

&

 

*
	
$ 


		
c             C   s_   |  j  ƒ  p d  S|  j j d ƒ |  j j d |  j t |  j ƒ f ƒ k o |  j ƒ  n d  S(   Nu   insertu   %s+%dc(   u	   is_activeu   widgetu   indexu
   startindexu   lenu   startu   hide_window(   u   selfu   event(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   keyrelease_eventj  s
    ,c             C   s   |  j  d  k	 S(   N(   u   autocompletewindowu   None(   u   self(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu	   is_activer  s    c             C   s   |  j  |  j |  j ƒ ƒ d  S(   N(   u   _change_startu   _complete_stringu   start(   u   self(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   completeu  s    c             C   sN  |  j  ƒ  p d  Sx! t D] } |  j j t | ƒ q W|  j j t |  j ƒ d  |  _ x! t D] } |  j j t	 | ƒ q\ W|  j j t	 |  j
 ƒ d  |  _
 |  j j t t ƒ |  j j t |  j ƒ d  |  _ |  j j t |  j ƒ d  |  _ |  j j t |  j ƒ d  |  _ |  j j ƒ  d  |  _ |  j j ƒ  d  |  _ |  j j ƒ  d  |  _ d  S(   N(   u	   is_activeu   HIDE_SEQUENCESu   widgetu   event_deleteu   HIDE_VIRTUAL_EVENT_NAMEu   unbindu   hideidu   Noneu   KEYPRESS_SEQUENCESu   KEYPRESS_VIRTUAL_EVENT_NAMEu
   keypressidu   KEYRELEASE_VIRTUAL_EVENT_NAMEu   KEYRELEASE_SEQUENCEu   keyreleaseidu   listboxu   LISTUPDATE_SEQUENCEu   listupdateidu   autocompletewindowu   WINCONFIG_SEQUENCEu   winconfigidu	   scrollbaru   destroy(   u   selfu   seq(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   hide_windowy  s4     	 						N(   u   __name__u
   __module__u   __init__u   _change_startu   _binary_searchu   _complete_stringu   _selection_changedu   show_windowu   winconfig_eventu
   hide_eventu   listselect_eventu   doubleclick_eventu   keypress_eventu   keyrelease_eventu	   is_activeu   completeu   hide_window(   u
   __locals__(    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   AutoCompleteWindow   s   
	 				$	D					j			u   AutoCompleteWindowN(   u
   <FocusOut>u   <ButtonPress>(
   u   <Key>u   <Key-BackSpace>u   <Key-Return>u	   <Key-Tab>u   <Key-Up>u
   <Key-Down>u
   <Key-Home>u	   <Key-End>u   <Key-Prior>u
   <Key-Next>(   u   __doc__u   tkinteru   idlelib.MultiCallu   MC_SHIFTu   idlelib.AutoCompleteu   COMPLETE_FILESu   COMPLETE_ATTRIBUTESu   HIDE_VIRTUAL_EVENT_NAMEu   HIDE_SEQUENCESu   KEYPRESS_VIRTUAL_EVENT_NAMEu   KEYPRESS_SEQUENCESu   KEYRELEASE_VIRTUAL_EVENT_NAMEu   KEYRELEASE_SEQUENCEu   LISTUPDATE_SEQUENCEu   WINCONFIG_SEQUENCEu   DOUBLECLICK_SEQUENCEu   AutoCompleteWindow(    (    (    u7   /mit/python/lib/python3.0/idlelib/AutoCompleteWindow.pyu   <module>   s   
  