eaiovnaovbqoebvqoeavibavo  V~gc@sdZddlZddlZddlZddlZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdJZdKZdLZdMZdNZ dOZ!ej"dkrdPdQdRdSfZ#eee e!fZ$n$dTdUdVdWfZ#eeeefZ$e%ge&e'e#D]#Z(e#e(D]Z)e)e(f^qbqTZ*d"dXd#YZ+e&de'e#>Z,ge,D]%Z-d$j.d%e/e#D^qZ0d&Z1e1e,Z2gZ3x]e,D]UZ-dZ4x9e&e'e#D]%Z5de5>e-@re4e$e5OZ4qqWe3j6e4qWd'dYd(YZ7dZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpfZ8e7fde+fe'e8dZ9e%ge&e'e8D]#Z(e8e(D]Z)e)e(f^qqZ:ej;dBZ<ej;dCZ=dDZ>dEZ?iZ@dFZAdGZBeCdHkrddIlDmEZEeEeBndS(qs 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. iNiiiiiiiiii i i i i iiiiiiiiitdarwintShifttControltOptiontCommandtAlttMetatMt _SimpleBindercBs,eZdZdZdZdZRS(cCsJ||_dt|dd|_||_||_g|_d|_dS(Nt(ttypet_typestsequencetwidgett widgetinstt bindedfuncstNonet handlerid(tselfR RR((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyt__init__Es     cCsV|jsB|j|jd}|jj|j|j||_n|jj|dS(NcSss||_i}x]tt|dddD]?}||}||kr,t||<||}|rk|Sq,q,WdS(Nii(tmc_typetrangetlentTrue(teventtlRt wascalledtitfunctr((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pythandlerOs #    (RRR RtbindRR tappend(RttripletRR((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyR Ms   cCsH|jj||jsD|jj|j|j|jd|_ndS(N(RtremoveRtunbindRR RR(RR"R((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyR$]s cCs/|jr+|jj|j|j|jndS(N(RRR$RR (R((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyt__del__cs (t__name__t __module__RR R$R%(((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyRDs   tccs1|]'\}}d|>t@r|ddVqdS(iit-N(ts(t.0Rtm((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pys ms csid}g}xS|D]Kttfd|D}|jd|dt|j|qW|S(sFor each item of states return a list containing all combinations of that item with individual bits reset, sorted by the number of set bits. cSs6d}x)|r1t|d\}}||7}q W|S(snumber of bits set in n base 2ii(tdivmod(tntnbtrem((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pytnbitsvs  c3s|]}|@VqdS(N((R+tx(tstate(s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pys stkeytreverse(tlisttsettsortRR!(tstatesR1t statelistt substates((R3s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pytexpand_substatesrs  "t_ComplexBindercBs5eZdZdZdZdZdZRS(cCs"||||j|jd}|S(Nc Sstg|(||_||_i}d}x||D]t}xatt|dddD]C} || } | |krRt|| <|| |}|rPqqRqRW|r/Pq/q/Wg|(x|D] } | qWg|(|r|SdS(Nii(RRtmc_stateRRR( RtlistsRR>tishandlerrunningtdoafterhandlerRRRRRtf((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyRs*    #      (R@RA(RR?RR>R((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyt__create_handlers c Cs||_t|d|_||_||_igtD] }g^q6d6|_g|_g|_ g|_ xtD]}gt |D]}|jd|^q}|j ||t |}dt||jd}|jj||jj|j||fqqWdS(NiR R (R R ttypenameRRt_statesRRt handleridsR@RAt_state_subsetst_ComplexBinder__create_handlert _state_codest _state_namesR!R ( RR RRR*RR?Rtseq((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyRs   #    (c s+djkrgtD] }g^qjdWnfd} js| njj | dS(Nis <%s%s-%s>cs jddjS(Nii(RR!((RRR"(s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pytR((RRERRGRHR RIRJRDRFR!RR RR@RA( RR"RR*tdetailRR?RRKtdoit((RRR"s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyR s$ (   cs<fd}js(|njj|dS(Ncs jddjS(Nii(RR#((RRR"(s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyRLR((R@RAR!(RR"RRN((RRR"s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyR$s  cCs7x0|jD]%\}}|jj|j||q WdS(N(RFRR$R(RRKtid((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyR%s(R&R'RHRR R$R%(((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyR=s     tKeyPresstKeyt KeyReleaset ButtonPresstButtont ButtonReleasetActivatet CirculatetColormapt Configuret DeactivatetDestroytEntertExposetFocusIntFocusOuttGravitytLeavetMaptMotiont MouseWheeltPropertytReparenttUnmapt Visibilitys^\w+$s^[1-5]$cCsc| s'|ddks'|ddkr+d Stj|dd!d}d}x7|r|dtkr|dt|d>O}|d=qMW|r|dtkrt|d}|d=nd St|tkr|s|rd Sd }nw|gd D]}t|^qkr t}nt}|s d }n6t |dkrR|j |drR|d}nd S|||fS( 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. iR iR iR)RPRRN(RPRR( Rtstringtsplitt_modifier_namest _type_namest_binder_classesRt _keysym_ret _button_reRtmatch(R twordst modifiersR RMR*ttype_re((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyt_parse_sequences0'    #  % cCsb|dr:dt|dt|ddd|ddSdt|dt|dddSdS(NiR iiR)R (RJR (R"((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyt_triplet_to_sequence's 0cs>tkrtSdffdY}|t<|S(sReturn 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 MultiCallcseZeejstfdZdddfdZdfdZ fdZ fdZ dfdZ dZ RS(csXj|||i|_gtttD]}t|||^q/|_dS(N(Rt_MultiCall__eventinfoRRR Rmt_MultiCall__binders(RtargstkwargsR(R(s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyR:s cs#t|tkr t|dkr |d dkr |ddkr ||jkr|j|}|ddk rx4|dD]%}|j|dj||dq{Wn||d<|ddk r x0|dD]!}|j|dj||qWq q |gg|j|>ii(R tstrRRwRRxR$R (RR RtaddteiR"(R(s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyR Cs$  & %cst|tkrt|dkr|d dkr|ddkr||jkr|j|\}}|dk rx)|D]!}|j|dj||qyWd|j|d>ii(R R{RRwRRxR$(RR tfuncidRttripletsR"(R(s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyR$Ts$   cs||jkr%dgg|j|>ii(R R(RKR.R(ttext(RKs6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pytbindseqsss s sssss ss ss( RtTkttitleR6RtinttreRjtgeometryRtTexttpacktmainloop(tparenttroottwidththeightR2tyR((Rs6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyt _multi_calls(  3             t__main__(truniiii i@i(R(R(R(R(R(R(R(RR(((RPRQ(RR(RSRT(RU(RV(RW(RX(RY(RZ(R[(R\(R](R^(R_(R`(Ra(Rb(Rc(Rd(Re(Rf(Rg(Rh(Ft__doc__tsysRiRRt MC_KEYPRESSt MC_KEYRELEASEtMC_BUTTONPRESStMC_BUTTONRELEASEt MC_ACTIVATEt MC_CIRCULATEt MC_COLORMAPt MC_CONFIGUREt MC_DEACTIVATEt MC_DESTROYtMC_ENTERt MC_EXPOSEt MC_FOCUSINt MC_FOCUSOUTt MC_GRAVITYtMC_LEAVEtMC_MAPt MC_MOTIONt MC_MOUSEWHEELt MC_PROPERTYt MC_REPARENTtMC_UNMAPt MC_VISIBILITYtMC_SHIFTt MC_CONTROLtMC_ALTtMC_METAt MC_OPTIONt MC_COMMANDtplatformt _modifierst_modifier_maskstdictRRtnumbertnameRkRRER*tjoint enumerateRJR<RGRIRRR!R=R RmRltcompileRnRoRtRuRRRR&tidlelib.idle_test.htestR(((s6/opt/alt/python27/lib64/python2.7/idlelib/MultiCall.pyts    & (/   \   "& *  b