;
Ñâ"Ic               @   sÁ  d  Z  d d l Z d d l Z d d l 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 Z d Z d Z d Z d Z d Z d Z d Z dU Z dV Z dW Z dX Z dY Z dZ Z  e j! d k o; e j" j# d ƒ o( d[ d\ d] d^ f Z$ e e e e  f Z% n% d_ d` da db f Z$ e e e e f Z% e& d" „  e' e( e$ ƒ ƒ Dƒ ƒ Z) Gd# „  d$ ƒ Z* e' d e( e$ ƒ >ƒ Z+ d% „  e+ Dƒ Z, d& „  Z- e- e+ ƒ Z. g  Z/ x_ e+ D]W Z0 d Z1 x; e' e( e$ ƒ ƒ D]' Z2 d e2 >e0 @o e1 e% e2 OZ1 qàqàWe/ j3 e1 ƒ qÁWGd' „  d( ƒ Z4 dc dd de df dg dh di dj dk dl dm dn do dp dq dr ds dt du dv dw dx dy f Z5 e4 f d e* f e( e5 ƒ d Z6 e& dB „  e' e( e5 ƒ ƒ Dƒ ƒ Z7 e j8 dC ƒ Z9 e j8 dD ƒ Z: dE „  Z; dF „  Z< i  Z= dG „  Z> e? dH k o¶ e j@ ƒ  ZA e> e jB ƒ eA ƒ ZC eC jD ƒ  d g dI „ ZE eE dJ ƒ eE dK ƒ eE dL ƒ eE dM ƒ eE dN ƒ eE dO ƒ eE dP ƒ eE dQ ƒ eE dR ƒ eE dS ƒ eE dT ƒ eA jF ƒ  n d S(z   u˜  
MultiCall - a class which inherits its methods from a Tkinter widget (Text, for
example), but enables multiple calls of functions per virtual event - all
matching events will be called, not only the most specific one. This is done
by wrapping the event functions - event_add, event_delete and event_info.
MultiCall recognizes only a subset of legal event sequences. Sequences which
are not recognized are treated by the original Tk handling mechanism. A
more-specific event will be called before a less-specific event.

The recognized sequences are complete one-event sequences (no emacs-style
Ctrl-X Ctrl-C, no shortcuts like <3>), for all types of events.
Key/Button Press/Release events can have modifiers.
The recognized modifiers are Shift, Control, Option and Command for Mac, and
Control, Alt, Shift, Meta/M for other platforms.

For all events which were handled by MultiCall, a new member is added to the
event instance passed to the binded functions - mc_type. This is one of the
event type constants defined in this module (such as MC_KEYPRESS).
For Key/Button events (which are handled by MultiCall and may receive
modifiers), another member is added - mc_state. This member gives the state
of the recognized modifiers, as a combination of the modifier constants
also defined in this module (for example, MC_SHIFT).
Using these members is absolutely portable.

The order by which events are called is defined by these rules:
1. A more-specific event will be called before a less-specific event.
2. A recently-binded event will be called before a previously-binded event,
   unless this conflicts with the first rule.
Each function will be called at most once for each event.
i    Ni   i   i   i   i   i   i   i   i	   i
   i   i   i   i   i   i   i   i   i   i   i   i   u   darwinu   .appu   Shiftu   Controlu   Optionu   Commandu   Altu   Metau   Mc             C   s2   g  } |  ]$ } t  | D] } | | | f q q
 S(    (   u
   _modifiers(   u   .0u   _[1]u   numberu   name(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu
   <listcomp>7   s   c             B   s2   |  Ee  Z d  „  Z d „  Z d „  Z d „  Z d S(   c             C   sJ   | |  _  d t | d d |  _ | |  _ | |  _ g  |  _ d  |  _ d  S(   Nu   <i    u   >(   u   typeu   _typesu   sequenceu   widgetu
   widgetinstu   bindedfuncsu   Noneu	   handlerid(   u   selfu   typeu   widgetu
   widgetinst(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   __init__D   s    				c             C   sX   |  j  p: |  j |  j d „ } |  j j |  j |  j | ƒ |  _  n |  j j | ƒ d  S(   Nc             S   sw   | |  _  i  } xa t t | ƒ d d d ƒ D]C } | | } | | k o& d | | <| |  ƒ } | o | Sq, q, Wd  S(   Ni   iÿÿÿÿT(   u   mc_typeu   rangeu   lenu   True(   u   eventu   lu   mc_typeu	   wascalledu   iu   funcu   r(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   handlerN   s    	 

(   u	   handleridu   bindedfuncsu   typeu   widgetu   bindu
   widgetinstu   sequenceu   append(   u   selfu   tripletu   funcu   handler(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   bindL   s
    

c             C   sJ   |  j  j | ƒ |  j  p, |  j j |  j |  j |  j ƒ d  |  _ n d  S(   N(   u   bindedfuncsu   removeu   widgetu   unbindu
   widgetinstu   sequenceu	   handleridu   None(   u   selfu   tripletu   func(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   unbind\   s    
c             C   s1   |  j  o# |  j j |  j |  j |  j  ƒ n d  S(   N(   u	   handleridu   widgetu   unbindu
   widgetinstu   sequence(   u   self(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   __del__b   s    
N(   u   __name__u
   __module__u   __init__u   bindu   unbindu   __del__(   u
   __locals__(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   _SimpleBinderC   s   
			u   _SimpleBinderc                s:   g  } |  ], ‰  | d  j  ‡  f d †  t t ƒ Dƒ ƒ q
 S(   u    c             3   s6   |  ], \ } } d  | >ˆ  @o | d d Vq q d S(   i   i    u   -N(    (   u   .0u   iu   m(   u   s(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu	   <genexpr>l   s   	(   u   joinu	   enumerateu
   _modifiers(   u   .0u   _[1](    (   u   su.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu
   <listcomp>l   s   c                si   d „  } g  } xS |  D]K ‰  t  t ‡  f d †  |  Dƒ ƒ ƒ } | j d | d d ƒ | j | ƒ q W| S(   u•   For each item of states return a list containing all combinations of
    that item with individual bits reset, sorted by the number of set bits.
    c             S   s8   d } x+ |  o# t  |  d ƒ \ }  } | | 7} q	 W| S(   u   number of bits set in n base 2i    i   (   u   divmod(   u   nu   nbu   rem(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   nbitsu   s     c             3   s   |  ] } ˆ  | @Vq d  S(   N(    (   u   .0u   x(   u   state(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu	   <genexpr>~   s    u   keyu   reverseT(   u   listu   setu   sortu   Trueu   append(   u   statesu   nbitsu	   statelistu	   substates(    (   u   stateu.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   expand_substatesq   s    	 "c             B   s;   |  Ee  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d S(   c             C   s"   | | | |  j  |  j d „ } | S(   Nc             S   sò   d g | d  d  … <| |  _ | |  _ i  } d  } x‚ | D]z } xe t t | ƒ d d d ƒ D]G }	 | |	 }
 |
 | k o* d | |
 <| |	 |  ƒ } | o Pq¢ q[ q[ W| o Pq8 q8 Wg  | d  d  … <x | o | j ƒ  ƒ  qÉ W| o | Sd  S(   Ni   iÿÿÿÿT(   u   Trueu   mc_typeu   mc_stateu   Noneu   rangeu   lenu   pop(   u   eventu   listsu   mc_typeu   mc_stateu   ishandlerrunningu   doafterhandleru	   wascalledu   ru   lu   iu   func(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   handler—   s.    		  

	 (   u   ishandlerrunningu   doafterhandler(   u   selfu   listsu   mc_typeu   mc_stateu   handler(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   __create_handler–   s
    c                sí   | ˆ  _  t | d ˆ  _ | ˆ  _ | ˆ  _ i d „  t Dƒ d  6ˆ  _ g  ˆ  _ g  ˆ  _	 g  ˆ  _
 x… t D]} } ‡  f d †  t | Dƒ } ˆ  j | | t | ƒ } d t | ˆ  j d } ˆ  j j | ˆ  j j ˆ  j | | ƒ f ƒ qh Wd  S(   Ni    c             S   s   g  } |  ] } | g  q
 S(    (    (   u   .0u   _[1]u   s(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu
   <listcomp>·   s    c                s&   g  } |  ] } | ˆ  j  d  | q
 S(   N(   u   bindedfuncsu   None(   u   .0u   _[1]u   i(   u   self(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu
   <listcomp>Ã   s    u   <u   >(   u   typeu   _typesu   typenameu   widgetu
   widgetinstu   _statesu   Noneu   bindedfuncsu
   handleridsu   ishandlerrunningu   doafterhandleru   _state_subsetsu   _ComplexBinder__create_handleru   _state_codesu   _state_namesu   appendu   bind(   u   selfu   typeu   widgetu
   widgetinstu   su   listsu   handleru   seq(    (   u   selfu.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   __init__²   s    						 c                s
  ˆ  d ˆ j  k o¸ d „  t Dƒ ˆ j  ˆ  d <xš t D]Ž ‰ ‡ ‡ f d †  ˆ  d d  f Dƒ } ˆ j | ˆ j t ˆ ƒ } d t ˆ ˆ j ˆ  d f } ˆ j j	 | ˆ j
 j ˆ j | | ƒ f ƒ q6 Wn ‡ ‡  ‡ f d †  } ˆ j p | ƒ  n ˆ j j	 | ƒ d  S(   Ni   c             S   s   g  } |  ] } | g  q
 S(    (    (   u   .0u   _[1]u   s(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu
   <listcomp>Ë   s    c                s7   g  } |  ]) } t  ˆ D] } | ˆ  j | | q q
 S(    (   u   _state_subsetsu   bindedfuncs(   u   .0u   _[1]u   detailu   i(   u   selfu   s(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu
   <listcomp>Í   s   u	   <%s%s-%s>c                  s    ˆ  j  ˆ d  ˆ d j ˆ ƒ S(   i   i    (   u   bindedfuncsu   append(    (   u   selfu   tripletu   func(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   <lambda>Õ   s    (   u   bindedfuncsu   _statesu   Noneu   _ComplexBinder__create_handleru   typeu   _state_codesu   _state_namesu   typenameu
   handleridsu   appendu   widgetu   bindu
   widgetinstu   ishandlerrunningu   doafterhandler(   u   selfu   tripletu   funcu   listsu   handleru   sequ   doit(    (   u   tripletu   selfu   su   funcu.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   bindÉ   s     
c                s>   ‡  ‡ ‡ f d †  } ˆ  j  p | ƒ  n ˆ  j j | ƒ d  S(   Nc                  s    ˆ  j  ˆ d  ˆ d j ˆ ƒ S(   i   i    (   u   bindedfuncsu   remove(    (   u   selfu   tripletu   func(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   <lambda>Ü   s    (   u   ishandlerrunningu   doafterhandleru   append(   u   selfu   tripletu   funcu   doit(    (   u   selfu   tripletu   funcu.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   unbindÛ   s    
c             C   s7   x0 |  j  D]% \ } } |  j j |  j | | ƒ q
 Wd  S(   N(   u
   handleridsu   widgetu   unbindu
   widgetinst(   u   selfu   sequ   id(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   __del__â   s    
 N(   u   __name__u
   __module__u   _ComplexBinder__create_handleru   __init__u   bindu   unbindu   __del__(   u
   __locals__(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   _ComplexBinderŽ   s
   
				u   _ComplexBinderu   KeyPressu   Keyu
   KeyReleaseu   ButtonPressu   Buttonu   ButtonReleaseu   Activateu	   Circulateu   Colormapu	   Configureu
   Deactivateu   Destroyu   Enteru   Exposeu   FocusInu   FocusOutu   Gravityu   Leaveu   Mapu   Motionu
   MouseWheelu   Propertyu   Reparentu   Unmapu
   Visibilityc             C   s2   g  } |  ]$ } t  | D] } | | | f q q
 S(    (   u   _types(   u   .0u   _[1]u   numberu   name(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu
   <listcomp>õ   s   u   ^\w+$u   ^[1-5]$c             C   sl  |  p" |  d d k p |  d d k o d
 S|  d d … j d ƒ } d } x: | o2 | d t k o! | d t | d >O} | d =qQ W| o* | d t k o t | d } | d =n d
 St | t k o | p | o d
 Sd
 } nr | d „  d Dƒ k o
 t } n t } | p
 d
 } n: t | ƒ d k o" | j	 | d ƒ o | d } n d
 S| | | f S(   u-  Get a string which should describe an event sequence. If it is
    successfully parsed as one, return a tuple containing the state (as an int),
    the event type (as an index of _types), and the detail - None if none, or a
    string if there is one. If the parsing is unsuccessful, return None.
    i    u   <iÿÿÿÿu   >i   u   -c             S   s   g  } |  ] } | t  | q
 S(    (   u   _type_names(   u   .0u   _[1]u   s(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu
   <listcomp>  s    u   KeyPressu
   KeyReleaseN(   u   KeyPressu
   KeyRelease(
   u   Noneu   splitu   _modifier_namesu   _type_namesu   _binder_classesu   _SimpleBinderu
   _keysym_reu
   _button_reu   lenu   match(   u   sequenceu   wordsu	   modifiersu   typeu   detailu   type_re(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   _parse_sequenceû   s2    * 


'c             C   sd   |  d o1 d t  |  d t |  d d d |  d d Sd t  |  d t |  d d d Sd  S(   Ni   u   <i    i   u   -u   >(   u   _state_namesu   _types(   u   triplet(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   _triplet_to_sequence"  s    1c                s=   ˆ  t  k o	 t  ˆ  SG‡  f d †  d ˆ  ƒ } | t  ˆ  <| S(   u©   Return a MultiCall class which inherits its methods from the
    given widget class (for example, Tkinter.Text). This is used
    instead of a templating mechanism.
    c                sš   |  Ee  Z e ˆ  e j ƒ p t ‚ ‡  f d  †  Z d d d ‡  f d † Z d ‡  f d † Z	 ‡  f d †  Z
 ‡  f d †  Z d ‡  f d † Z d „  Z d S(   c                sH   ˆ j  ˆ  | | Ž i  ˆ  _ ‡ ‡  f d †  t t t ƒ ƒ Dƒ ˆ  _ d  S(   Nc                s+   g  } |  ] } | t  | | ˆ  ˆ ƒ q
 S(    (   u   _binder_classes(   u   .0u   _[1]u   i(   u   widgetu   self(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu
   <listcomp>;  s   (   u   __init__u   _MultiCall__eventinfou   rangeu   lenu   _typesu   _MultiCall__binders(   u   selfu   argsu   kwargs(   u   widget(   u   selfu.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   __init__5  s    	c          	      s:  t  | ƒ t k ot | ƒ d k oþ | d  d … d k oç | d d  … d k oÐ | |  j k o© |  j | } | d d  k	 o8 x5 | d D]% } |  j | d j | | d ƒ q Wn | | d <| d d  k	 o4 x1 | d D]! } |  j | d j | | ƒ qà Wq q$| g  g |  j | <n ˆ  j |  | | | ƒ S(   Ni   u   <<iþÿÿÿu   >>i    i   (   u   typeu   stru   lenu   _MultiCall__eventinfou   Noneu   _MultiCall__bindersu   unbindu   bind(   u   selfu   sequenceu   funcu   addu   eiu   triplet(   u   widget(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   bind>  s    &. '
 'c                sÜ   t  | ƒ t k o¶ t | ƒ d k o£ | d  d … d k oŒ | d d  … d k ou | |  j k oe |  j | \ } } | d  k	 oA x) | D]! } |  j | d j | | ƒ q‹ Wd  |  j | d <qÉ n ˆ  j |  | | ƒ S(   Ni   u   <<iþÿÿÿu   >>i   i    (   u   typeu   stru   lenu   _MultiCall__eventinfou   Noneu   _MultiCall__bindersu   unbind(   u   selfu   sequenceu   funcidu   funcu   tripletsu   triplet(   u   widget(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   unbindP  s    &. c                s¸   | |  j  k o d  g  g |  j  | <n |  j  | \ } } xw | D]o } t | ƒ } | d  k o ˆ  j |  | | ƒ qA | d  k	 o |  j | d j | | ƒ n | j | ƒ qA Wd  S(   Ni   (   u   _MultiCall__eventinfou   Noneu   _parse_sequenceu	   event_addu   _MultiCall__bindersu   bindu   append(   u   selfu   virtualu	   sequencesu   funcu   tripletsu   sequ   triplet(   u   widget(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu	   event_add[  s     c                s¦   | |  j  k o d  S|  j  | \ } } xw | D]o } t | ƒ } | d  k o ˆ  j |  | | ƒ q/ | d  k	 o |  j | d j | | ƒ n | j | ƒ q/ Wd  S(   Ni   (   u   _MultiCall__eventinfou   _parse_sequenceu   Noneu   event_deleteu   _MultiCall__bindersu   unbindu   remove(   u   selfu   virtualu	   sequencesu   funcu   tripletsu   sequ   triplet(   u   widget(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   event_deletel  s     c                s`   | d  k p | |  j k o ˆ  j |  | ƒ St t t |  j | d ƒ ƒ ˆ  j |  | ƒ Sd  S(   Ni   (   u   Noneu   _MultiCall__eventinfou
   event_infou   tupleu   mapu   _triplet_to_sequence(   u   selfu   virtual(   u   widget(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu
   event_infoz  s
    	c             S   sb   x[ |  j  D]P } |  j  | \ } } | o0 x- | D]! } |  j | d j | | ƒ q1 Wq
 q
 Wd  S(   Ni   (   u   _MultiCall__eventinfou   _MultiCall__bindersu   unbind(   u   selfu   virtualu   funcu   tripletsu   triplet(    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   __del__‚  s    
  N(   u   __name__u
   __module__u
   issubclassu   tkinteru   Miscu   AssertionErroru   __init__u   Noneu   bindu   unbindu	   event_addu   event_deleteu
   event_infou   __del__(   u
   __locals__(   u   widget(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu	   MultiCall2  s   
	u	   MultiCall(   u   _multicall_dict(   u   widgetu	   MultiCall(    (   u   widgetu.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   MultiCallCreator*  s
    	X
u   __main__c                sS   ‡  f d †  } t  j d | d | ƒ t  j d | d ˆ  ƒ | d c d 7<d  S(   Nc                s   t  ˆ  ƒ d  S(   N(   u   print(   u   event(   u   seq(    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   handler“  s    u   <<handler%d>>i    i   (   u   textu   bindu	   event_add(   u   sequ   nu   handler(    (   u   sequ.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   bindseq’  s    u   <Key>u   <Control-Key>u   <Alt-Key-a>u   <Control-Key-a>u   <Alt-Control-Key-a>u   <Key-b>u   <Control-Button-1>u   <Alt-Button-1>u
   <FocusOut>u   <Enter>u   <Leave>i   i   i   i    i@   i€   (   u   Shift(   u   Control(   u   Option(   u   Command(   u   Control(   u   Alt(   u   Shift(   u   Metau   M(   u   KeyPressu   Key(   u
   KeyRelease(   u   ButtonPressu   Button(   u   ButtonRelease(   u   Activate(   u	   Circulate(   u   Colormap(   u	   Configure(   u
   Deactivate(   u   Destroy(   u   Enter(   u   Expose(   u   FocusIn(   u   FocusOut(   u   Gravity(   u   Leave(   u   Map(   u   Motion(   u
   MouseWheel(   u   Property(   u   Reparent(   u   Unmap(   u
   Visibility(G   u   __doc__u   sysu   reu   tkinteru   MC_KEYPRESSu   MC_KEYRELEASEu   MC_BUTTONPRESSu   MC_BUTTONRELEASEu   MC_ACTIVATEu   MC_CIRCULATEu   MC_COLORMAPu   MC_CONFIGUREu   MC_DEACTIVATEu
   MC_DESTROYu   MC_ENTERu	   MC_EXPOSEu
   MC_FOCUSINu   MC_FOCUSOUTu
   MC_GRAVITYu   MC_LEAVEu   MC_MAPu	   MC_MOTIONu   MC_MOUSEWHEELu   MC_PROPERTYu   MC_REPARENTu   MC_UNMAPu   MC_VISIBILITYu   MC_SHIFTu
   MC_CONTROLu   MC_ALTu   MC_METAu	   MC_OPTIONu
   MC_COMMANDu   platformu
   executableu   countu
   _modifiersu   _modifier_masksu   dictu   rangeu   lenu   _modifier_namesu   _SimpleBinderu   _statesu   _state_namesu   expand_substatesu   _state_subsetsu   _state_codesu   su   ru   iu   appendu   _ComplexBinderu   _typesu   _binder_classesu   _type_namesu   compileu
   _keysym_reu
   _button_reu   _parse_sequenceu   _triplet_to_sequenceu   _multicall_dictu   MultiCallCreatoru   __name__u   Tku   rootu   Textu   textu   packu   bindsequ   mainloop(    (    (    u.   /mit/python/lib/python3.0/idlelib/MultiCall.pyu   <module>   s®                         #	(
	  [		"		'		c











