Ñò
—à"Ic        #   @   s³  d  Z  d d k Z d d k Z d d k Z d d k 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 dY Z dZ Z d[ Z d\ Z d] Z  d^ Z! e i" d j o; e i# i$ d ƒ o( d_ d` da db f Z% e e e  e! f Z& n% dc dd de df f Z% e e e e f Z& e' g  Z( e) e* e% ƒ ƒ D]$ Z+ e% e+ D] Z, e( e, e+ f q{qm[( ƒ Z- d# dg d$ „  ƒ  YZ. e) d e* e% ƒ >ƒ Z/ g  Z0 e/ D]b Z1 e0 e2 d% „  g  Z3 e) e* e% ƒ ƒ D], Z4 d e4 >e1 @o e3 e% e4 d d& qúqú[3 d' ƒ qÑ[0 Z5 e6 d( „  e/ ƒ Z7 x$ e7 D] Z8 e8 i9 d) „  d* „ ƒ qUWg  Z: e/ D]Z Z1 e: e2 d+ „  g  Z; e) e* e% ƒ ƒ D]$ Z4 d e4 >e1 @o e; e& e4 q©q©[; d ƒ q€[: Z< d, dh d- „  ƒ  YZ= di dj dk dl dm dn do dp dq dr ds dt du dv dw dx dy dz d{ d| d} d~ d f Z> e= f d e. f e* e> ƒ d Z? e' g  Z@ e) e* e> ƒ ƒ D]$ Z+ e> e+ D] Z, e@ e, e+ f q‹q}[@ ƒ ZA e iB dG ƒ ZC e iB dH ƒ ZD dI „  ZE dJ „  ZF h  ZG dK „  ZH eI dL j o¶ e iJ ƒ  ZK eH e iL ƒ eK ƒ ZM eM iN ƒ  d g dM „ ZO eO dN ƒ eO dO ƒ eO dP ƒ eO dQ ƒ eO dR ƒ eO dS ƒ eO dT ƒ eO dU ƒ eO dV ƒ eO dW ƒ eO dX ƒ eK iP ƒ  n d S(€   s˜  
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   i   t   darwins   .appt   Shiftt   Controlt   Optiont   Commandt   Altt   Metat   Mt   _SimpleBinderc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   sJ   | |  _  d t | d d |  _ | |  _ | |  _ g  |  _ d  |  _ d  S(   Nt   <i    t   >(   t   typet   _typest   sequencet   widgett
   widgetinstt   bindedfuncst   Nonet	   handlerid(   t   selfR   R   R   (    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyt   __init__E   s    				c         C   sX   |  i  p: |  i |  i d „ } |  i i |  i |  i | ƒ |  _  n |  i i | ƒ d  S(   Nc         S   sw   | |  _  h  } xa t t | ƒ d d d ƒ D]C } | | } | | j o& t | | <| |  ƒ } | o | Sq, q, Wd  S(   Ni   iÿÿÿÿ(   t   mc_typet   ranget   lent   True(   t   eventt   lR   t	   wascalledt   it   funct   r(    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyt   handlerO   s    	 

(   R   R   R   R   t   bindR   R   t   append(   R   t   tripletR   R   (    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR    M   s
    

c         C   sJ   |  i  i | ƒ |  i  p, |  i i |  i |  i |  i ƒ d  |  _ n d  S(   N(   R   t   removeR   t   unbindR   R   R   R   (   R   R"   R   (    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR$   ]   s    
c         C   s1   |  i  o# |  i i |  i |  i |  i  ƒ n d  S(   N(   R   R   R$   R   R   (   R   (    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyt   __del__c   s    
(   t   __name__t
   __module__R   R    R$   R%   (    (    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR   D   s   			c         C   s   |  | S(    (    (   t   xt   y(    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyt   <lambda>m   s    t   -t    c            s   t  ‡  f d  †  t ƒ S(   c            s
   |  ˆ  @S(    (    (   t   j(   R   (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR*   r   s    (   t   filtert   _states(   R   (    (   R   s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR*   r   s    c            s(   t  t ‡  f d  †  t t  t ƒ ƒ ƒ ƒ S(   c            s   d  |  >ˆ  @S(   i   (    (   R   (   R(   (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR*   u   s    (   R   R.   R   t
   _modifiers(   R(   (    (   R(   s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR*   u   s   c         C   s   | | ƒ | |  ƒ S(    (    (   t   at   bt   nummod(    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR*   u   s    c         C   s   |  | BS(    (    (   R(   R)   (    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR*   y   s    t   _ComplexBinderc           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s"   | | | |  i  |  i d „ } | S(   Nc         S   sà   t  g | (| |  _ | |  _ h  } d  } x‚ | D]z } xe t t | ƒ d d d ƒ D]G }	 | |	 }
 |
 | j o* t  | |
 <| |	 |  ƒ } | o Pq™ qR qR W| o Pq/ q/ Wg  | (x | o | i ƒ  ƒ  q· W| o | Sd  S(   Ni   iÿÿÿÿ(   R   R   t   mc_stateR   R   R   t   pop(   R   t   listsR   R5   t   ishandlerrunningt   doafterhandlerR   R   R   R   R   (    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR   ˆ   s.    
		  

	 (   R8   R9   (   R   R7   R   R5   R   (    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyt   __create_handler‡   s
    c         C   s  | |  _  t | d |  _ | |  _ | |  _ h g  } t D] } | g  q: ~ d  6|  _ g  |  _ g  |  _	 g  |  _
 x› t D]“ } g  } t | D] } | |  i d  | qŽ ~ } |  i | | t | ƒ }	 d t | |  i d }
 |  i i |
 |  i i |  i |
 |	 ƒ f ƒ qy Wd  S(   Ni    R	   R
   (   R   R   t   typenameR   R   R/   R   R   t
   handleridsR8   R9   t   _state_subsetst   _ComplexBinder__create_handlert   _state_codest   _state_namesR!   R    (   R   R   R   R   t   _[1]t   st   _[2]R   R7   R   t   seq(    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR   £   s    			+			 0c            sB  ˆ i  i ˆ  d ƒ pí g  } t D] } | g  q" ~ ˆ i  ˆ  d <x¾ t D]² } g  } ˆ  d d  f D]) } t | D] } | ˆ i  | | qs qe ~ } ˆ i | ˆ i t | ƒ }	 d t | ˆ i	 ˆ  d f }
 ˆ i
 i |
 ˆ i i ˆ i |
 |	 ƒ f ƒ qJ Wn ‡ ‡  ‡ f d †  } ˆ i p | ƒ  n ˆ i i | ƒ d  S(   Ni   s	   <%s%s-%s>c              s    ˆ  i  ˆ d  ˆ d i ˆ ƒ S(   i   i    (   R   R!   (    (   R   R"   R   (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR*   Æ   s    (   R   t   has_keyR/   R   R=   R>   R   R?   R@   R;   R<   R!   R   R    R   R8   R9   (   R   R"   R   RA   RB   RC   t   detailR   R7   R   RD   t   doit(    (   R"   R   R   s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR    º   s     , ,
c            s>   ‡  ‡ ‡ f d †  } ˆ  i  p | ƒ  n ˆ  i i | ƒ d  S(   Nc              s    ˆ  i  ˆ d  ˆ d i ˆ ƒ S(   i   i    (   R   R#   (    (   R   R"   R   (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR*   Í   s    (   R8   R9   R!   (   R   R"   R   RG   (    (   R   R"   R   s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR$   Ì   s    
c         C   s7   x0 |  i  D]% \ } } |  i i |  i | | ƒ q
 Wd  S(   N(   R<   R   R$   R   (   R   RD   t   id(    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR%   Ó   s    
 (   R&   R'   R>   R   R    R$   R%   (    (    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR4      s
   				t   KeyPresst   Keyt
   KeyReleaset   ButtonPresst   Buttont   ButtonReleaset   Activatet	   Circulatet   Colormapt	   Configuret
   Deactivatet   Destroyt   Entert   Exposet   FocusInt   FocusOutt   Gravityt   Leavet   Mapt   Motiont
   MouseWheelt   Propertyt   Reparentt   Unmapt
   Visibilitys   ^\w+$s   ^[1-5]$c         C   s  |  p" |  d d j p |  d d j o d	 St i |  d d !d ƒ } d } x: | o2 | d t j o! | d t | d >O} | d =qQ W| o* | d t j o t | d } | d =n d	 St | t j o | p | o d	 Sd	 } n‡ | g  } d
 D] } | t | qü ~ j o
 t } n t } | p
 d	 } n: t	 | ƒ d j o" | i
 | d ƒ o | d } n d	 S| | | f S(   s-  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    R	   iÿÿÿÿR
   i   R+   RI   RK   N(   RI   RK   (   R   t   stringt   splitt   _modifier_namest   _type_namest   _binder_classesR   t
   _keysym_ret
   _button_reR   t   match(   R   t   wordst	   modifiersR   RF   RA   RB   t   type_re(    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyt   _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   R	   i    i   R+   R
   (   R@   R   (   R"   (    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyt   _triplet_to_sequence  s    1c            s@   ˆ  t  j o	 t  ˆ  Sd ˆ  f ‡  f d †  ƒ  Y} | t  ˆ  <| S(   s©   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.
    t	   MultiCallc              sz   e  Z ‡  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	 RS(   c            sg   t  ˆ  i |  f | | ƒ h  |  _ g  } t t t ƒ ƒ D] } | t | | ˆ  |  ƒ q: ~ |  _ d  S(   N(   t   applyR   t   _MultiCall__eventinfoR   R   R   Rf   t   _MultiCall__binders(   R   t   argst   kwargsRA   R   (   R   (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR   )  s    	c            s.  t  | ƒ t j ot | ƒ d j oò | d  d j oá | d d j oÐ | |  i j o© |  i | } | d d  j	 o8 x5 | d D]% } |  i | d i | | d ƒ q Wn | | d <| d d  j	 o4 x1 | d D]! } |  i | d i | | ƒ qÔ Wqq| g  g |  i | <n ˆ  i |  | | | ƒ S(   Ni   s   <<iþÿÿÿs   >>i    i   (   R   t   strR   Rq   R   Rr   R$   R    (   R   R   R   t   addt   eiR"   (   R   (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR    2  s    &" '
 'c            sÐ   t  | ƒ t j oª t | ƒ d j o— | d  d j o† | d d j ou | |  i j oe |  i | \ } } | d  j	 oA x) | D]! } |  i | d i | | ƒ q Wd  |  i | d <q½ n ˆ  i |  | | ƒ S(   Ni   s   <<iþÿÿÿs   >>i   i    (   R   Ru   R   Rq   R   Rr   R$   (   R   R   t   funcidR   t   tripletsR"   (   R   (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR$   C  s    &" c            s¸   | |  i  j o d  g  g |  i  | <n |  i  | \ } } xw | D]o } t | ƒ } | d  j o ˆ  i |  | | ƒ qA | d  j	 o |  i | d i | | ƒ n | i | ƒ qA Wd  S(   Ni   (   Rq   R   Rm   t	   event_addRr   R    R!   (   R   t   virtualt	   sequencesR   Ry   RD   R"   (   R   (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyRz   N  s     c            s¦   | |  i  j o d  S|  i  | \ } } xw | D]o } t | ƒ } | d  j o ˆ  i |  | | ƒ q/ | d  j	 o |  i | d i | | ƒ n | i | ƒ q/ Wd  S(   Ni   (   Rq   Rm   R   t   event_deleteRr   R$   R#   (   R   R{   R|   R   Ry   RD   R"   (   R   (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR}   ^  s     c            s`   | d  j p | |  i j o ˆ  i |  | ƒ St t t |  i | d ƒ ƒ ˆ  i |  | ƒ Sd  S(   Ni   (   R   Rq   t
   event_infot   tuplet   mapRn   (   R   R{   (   R   (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR~   l  s
    	c         S   sb   x[ |  i  D]P } |  i  | \ } } | o0 x- | D]! } |  i | d i | | ƒ q1 Wq
 q
 Wd  S(   Ni   (   Rq   Rr   R$   (   R   R{   R   Ry   R"   (    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR%   t  s    
  N(
   R&   R'   R   R   R    R$   Rz   R}   R~   R%   (    (   R   (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyRo   &  s   	(   t   _multicall_dict(   R   Ro   (    (   R   s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyt   MultiCallCreator  s
    	V
t   __main__c            sS   ‡  f d †  } t  i d | d | ƒ t  i d | d ˆ  ƒ | d c d 7<d  S(   Nc            s	   ˆ  GHd  S(   N(    (   R   (   RD   (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyR   …  s    s   <<handler%d>>i    i   (   t   textR    Rz   (   RD   t   nR   (    (   RD   s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyt   bindseq„  s    s   <Key>s   <Control-Key>s   <Alt-Key-a>s   <Control-Key-a>s   <Alt-Control-Key-a>s   <Key-b>s   <Control-Button-1>s   <Alt-Button-1>s
   <FocusOut>s   <Enter>s   <Leave>i   i   i   i    i@   i€   (   R   (   R   (   R   (   R   (   R   (   R   (   R   (   R   R   (    (    (   s   KeyPressRJ   (   s
   KeyRelease(   RL   RM   (   RN   (   RO   (   RP   (   RQ   (   RR   (   RS   (   RT   (   RU   (   RV   (   RW   (   RX   (   RY   (   RZ   (   R[   (   R\   (   R]   (   R^   (   R_   (   R`   (   Ra   (Q   t   __doc__t   sysRb   t   ret   Tkintert   MC_KEYPRESSt   MC_KEYRELEASEt   MC_BUTTONPRESSt   MC_BUTTONRELEASEt   MC_ACTIVATEt   MC_CIRCULATEt   MC_COLORMAPt   MC_CONFIGUREt   MC_DEACTIVATEt
   MC_DESTROYt   MC_ENTERt	   MC_EXPOSEt
   MC_FOCUSINt   MC_FOCUSOUTt
   MC_GRAVITYt   MC_LEAVEt   MC_MAPt	   MC_MOTIONt   MC_MOUSEWHEELt   MC_PROPERTYt   MC_REPARENTt   MC_UNMAPt   MC_VISIBILITYt   MC_SHIFTt
   MC_CONTROLt   MC_ALTt   MC_METAt	   MC_OPTIONt
   MC_COMMANDt   platformt
   executablet   countR0   t   _modifier_maskst   dictRA   R   R   t   numbert   nameRd   R   R/   RC   RB   t   reducet   _[3]R   R@   R€   R=   R   t   sortt   _[4]t   _[5]R?   R4   R   Rf   t   _[6]Re   t   compileRg   Rh   Rm   Rn   R   R‚   R&   t   Tkt   roott   TextR„   t   packR†   t   mainloop(    (    (    s.   /mit/python/lib/python2.6/idlelib/MultiCall.pyt   <module>   s¬                         #
*
(o		 g[		"
*	*		a











