³ò
›\Kc        $   @   s¿  d  Z  d d k 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‡qy[) ƒ Z. d# dg d$ „  ƒ  YZ/ e* d e+ e& ƒ >ƒ Z0 g  Z1 e0 D]b Z2 e1 e3 d% „  g  Z4 e* e+ e& ƒ ƒ D], Z5 d e5 >e2 @o e4 e& e5 d d& qq[4 d' ƒ qÝ[1 Z6 e7 d( „  e0 ƒ Z8 x$ e8 D] Z9 e9 i: d) „  d* „ ƒ qaWg  Z; e0 D]Z Z2 e; e3 d+ „  g  Z< e* e+ e& ƒ ƒ D]$ Z5 d e5 >e2 @o e< e' e5 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  ZA e* e+ e? ƒ ƒ D]$ Z, e? e, D] Z- eA e- e, f q—q‰[A ƒ ZB e iC dG ƒ ZD e iC dH ƒ ZE dI „  ZF dJ „  ZG h  ZH dK „  ZI eJ dL j o¶ e iK ƒ  ZL eI e iM ƒ eL ƒ ZN eN iO ƒ  d g dM „ ZP eP dN ƒ eP dO ƒ eP dP ƒ eP dQ ƒ eP dR ƒ eP dS ƒ eP dT ƒ eP dU ƒ eP dV ƒ eP dW ƒ eP dX ƒ eL iQ ƒ  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'   /usr/lib/python2.5/idlelib/MultiCall.pyt   __init__F   s    				c         C   sX   |  i  p: |  i |  i d „ } |  i i |  i |  i | ƒ |  _  n |  i i | ƒ d  S(   Nc         S   sz   | |  _  h  } xd t t | ƒ d d d ƒ D]F } | | } | | j o) t | | <| |  ƒ } | o | Sqr q, q, Wd  S(   Ni   iÿÿÿÿ(   t   mc_typet   ranget   lent   True(   t   eventt   lR   t	   wascalledt   it   funct   r(    (    s'   /usr/lib/python2.5/idlelib/MultiCall.pyt   handlerP   s    	 

(   R   R   R   R   t   bindR   R   t   append(   R   t   tripletR   R   (    (    s'   /usr/lib/python2.5/idlelib/MultiCall.pyR    N   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'   /usr/lib/python2.5/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'   /usr/lib/python2.5/idlelib/MultiCall.pyt   __del__d   s    
(   t   __name__t
   __module__R   R    R$   R%   (    (    (    s'   /usr/lib/python2.5/idlelib/MultiCall.pyR   E   s   			c         C   s   |  | S(    (    (   t   xt   y(    (    s'   /usr/lib/python2.5/idlelib/MultiCall.pyt   <lambda>n   s    t   -t    c            s   t  ‡  f d  †  t ƒ S(   c            s
   |  ˆ  @S(    (    (   t   j(   R   (    s'   /usr/lib/python2.5/idlelib/MultiCall.pyR*   s   s    (   t   filtert   _states(   R   (    (   R   s'   /usr/lib/python2.5/idlelib/MultiCall.pyR*   s   s    c            s(   t  t ‡  f d  †  t t  t ƒ ƒ ƒ ƒ S(   c            s   d  |  >ˆ  @S(   i   (    (   R   (   R(   (    s'   /usr/lib/python2.5/idlelib/MultiCall.pyR*   v   s    (   R   R.   R   t
   _modifiers(   R(   (    (   R(   s'   /usr/lib/python2.5/idlelib/MultiCall.pyR*   v   s   c         C   s   | | ƒ | |  ƒ S(    (    (   t   at   bt   nummod(    (    s'   /usr/lib/python2.5/idlelib/MultiCall.pyR*   v   s    c         C   s   |  | BS(    (    (   R(   R)   (    (    s'   /usr/lib/python2.5/idlelib/MultiCall.pyR*   z   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 | Sn 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'   /usr/lib/python2.5/idlelib/MultiCall.pyR   ‰   s.    
		  

	 (   R8   R9   (   R   R7   R   R5   R   (    (    s'   /usr/lib/python2.5/idlelib/MultiCall.pyt   __create_handlerˆ   s
    c         C   s  | |  _  t | d |  _ | |  _ | |  _ h  g  } t D] } | g  q; ~ d  <|  _ g  |  _ g  |  _	 g  |  _
 x› t D]“ } g  } t | D] } | |  i d  | q ~ } |  i | | t | ƒ }	 d t | |  i d }
 |  i i |
 |  i i |  i |
 |	 ƒ f ƒ q{ 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'   /usr/lib/python2.5/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'   /usr/lib/python2.5/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'   /usr/lib/python2.5/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'   /usr/lib/python2.5/idlelib/MultiCall.pyR*   Î   s    (   R8   R9   R!   (   R   R"   R   RG   (    (   R   R"   R   s'   /usr/lib/python2.5/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'   /usr/lib/python2.5/idlelib/MultiCall.pyR%   Ô   s    
 (   R&   R'   R>   R   R    R$   R%   (    (    (    s'   /usr/lib/python2.5/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	 Sn t i |  d d !d ƒ } d } x: | o2 | d t j o! | d t | d >O} | d =qT W| o* | d t j o t | d } | d =n d	 St | t j o  | p | o d	 Sqz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'   /usr/lib/python2.5/idlelib/MultiCall.pyt   _parse_sequenceí   s2    * 
,

'c         C   sg   |  d o4 d t  |  d t |  d d d |  d d Sn% d t  |  d t |  d d d Sd  S(   Ni   R	   i    i   R+   R
   (   R@   R   (   R"   (    (    s'   /usr/lib/python2.5/idlelib/MultiCall.pyt   _triplet_to_sequence  s    4c            sC   ˆ  t  j o t  ˆ  Sn 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              s”   e  Z e ˆ  e i ƒ 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 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'   /usr/lib/python2.5/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'   /usr/lib/python2.5/idlelib/MultiCall.pyR    3  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'   /usr/lib/python2.5/idlelib/MultiCall.pyR$   D  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'   /usr/lib/python2.5/idlelib/MultiCall.pyRz   O  s     c            s©   | |  i  j o d  Sn |  i  | \ } } xw | D]o } t | ƒ } | d  j o ˆ  i |  | | ƒ q2 | d  j	 o |  i | d i | | ƒ n | i | ƒ q2 Wd  S(   Ni   (   Rq   Rm   R   t   event_deleteRr   R$   R#   (   R   R{   R|   R   Ry   RD   R"   (   R   (    s'   /usr/lib/python2.5/idlelib/MultiCall.pyR}   _  s     c            sc   | d  j p | |  i j o ˆ  i |  | ƒ Sn/ t t t |  i | d ƒ ƒ ˆ  i |  | ƒ Sd  S(   Ni   (   R   Rq   t
   event_infot   tuplet   mapRn   (   R   R{   (   R   (    s'   /usr/lib/python2.5/idlelib/MultiCall.pyR~   m  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'   /usr/lib/python2.5/idlelib/MultiCall.pyR%   u  s    
  N(   R&   R'   t
   issubclasst   Tkintert   Misct   AssertionErrorR   R   R    R$   Rz   R}   R~   R%   (    (   R   (    s'   /usr/lib/python2.5/idlelib/MultiCall.pyRo   '  s   	(   t   _multicall_dict(   R   Ro   (    (   R   s'   /usr/lib/python2.5/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'   /usr/lib/python2.5/idlelib/MultiCall.pyR   †  s    s   <<handler%d>>i    i   (   t   textR    Rz   (   RD   t   nR   (    (   RD   s'   /usr/lib/python2.5/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   (R   t   __doc__t   syst   osRb   t   reR‚   t   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'   /usr/lib/python2.5/idlelib/MultiCall.pys   <module>   s®                         #
*
(o		 g[		"
*	*		a











