ó p”þfc @sƒdZddlTddlmZddlmZmZdZdZdZ dZ dZ dZ dZ dZdZddd„ƒYZdS(sH An auto-completion window for IDLE, used by the AutoComplete extension iÿÿÿÿ(t*(tMC_SHIFT(tCOMPLETE_FILEStCOMPLETE_ATTRIBUTESs<>s s s<>sss s ss s s s s s!<>s ss stAutoCompleteWindowcBseZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„ZRS(cCs¨||_d|_|_|_d|_|_d|_d|_d|_ d|_ d|_ d|_ d|_ d|_|_|_|_|_|_t|_dS(N(twidgettNonetautocompletewindowtlistboxt scrollbartorigselforegroundtorigselbackgroundt completionstmorecompletionstmodetstartt startindextlasttypedstarttuserwantswindowthideidt keypressidt listupdateidt winconfigidt keyreleaseidt doubleclickidtFalsetlastkey_was_tab(tselfR((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyt__init__s        ,cCsìtt|jƒt|ƒƒ}d}x1||krW|j|||krW|d7}q'W|t|jƒkr¦|jjd|j|fd|jt|jƒfƒn|t|ƒkrß|jjd|j|f||ƒn||_dS(Niis%s+%dc(tmintlenRRtdeleteRtinsert(Rtnewstarttmin_lenti((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyt _change_start8s& cCsvd}t|jƒ}xD||kr[||d}|j||krN|}q|d}qWt|t|jƒdƒS(s’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.iii(RR R(RtsR#tjtm((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyt_binary_searchEs c Cs5|j|ƒ}|j|t|ƒ |kr0|S|d}t|jƒ}xN||kr™||d}|j|t|ƒ |krŒ|}qL|d}qLW|d}||kr»|j|S|j|}|j|}tt|ƒt|ƒƒ} t|ƒ}x.|| kr,||||kr,|d7}qÿW|| S(sÖ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.ii(R(R RR( RR%tfirstR#R&R'tlastt first_compt last_compR"((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyt_complete_stringRs(        #cCsÁt|jjƒdƒ}|jj|ƒ|j}|j|}|j|ƒ|kr]|}n\tt|ƒt|ƒƒ}d}x.||kr®||||kr®|d7}qW|| }|j |ƒ|j|t|j ƒ |j kr |jj d|j d|j ƒn²|jj d|jjdƒd|jjdƒƒ|jr½|j|_d|_|jjdtƒx$|jD]}|jjt|ƒqwW|jj|j|j ƒƒ|jƒndS(s|Should be called when the selection of the Listbox has changed. Updates the Listbox display and calls _change_start.iitselectbackgroundtselectforegroundtbgtfgN(tintRt curselectiontseeRR R(RRR$Rt configureR R tcgetR RRtENDR t select_sett_selection_changed(RtcurseltltstselstartR!R"R#titem((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyR9qs2   #  #    c Cs;|\|_|_||_|jj|ƒ|_|jj|jdƒ|_|rÓ|j|jƒ}|j |ƒ|j |ƒ}|j||krÓ|t |jƒdksÌ|j|dt |ƒ |krÓdSn||_ |j|_ t|jƒ|_}|jdƒ|jdƒy#|jjdd|jddƒWntk rNnXt|d tƒ|_} t|d | jd td d ƒ|_} x!|jD]} | jt| ƒqšW| jdƒ|_ | jdƒ|_!| j"d| j#ƒ| j$dt%dt&ƒ| j$dt'dt(dt)ƒ|jj*|j |jƒƒ|j+ƒ|jj,t-|j.ƒ|_/x!t0D]} |jj1t-| ƒqeW|jj,t2|j3ƒ|_4x!t5D]} |jj1t2| ƒq¤W|jj,t6|j7ƒ|_8|jj1t6t9ƒ| j,t:|j;ƒ|_<|j,t=|j>ƒ|_?| j,t@|jAƒ|_BdS(s¤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.R iNs +10000+10000s!::tk::unsupported::MacWindowStyletstylethelpt noActivatestorienttyscrollcommandtexportselectionR0twhiteR/R.tcommandtsidetfilltexpand(CR R RRtindexRtgetRR-R$R(RRRtToplevelRt wm_geometrytwm_overrideredirectttktcallt_wtTclErrort ScrollbartVERTICALR tListboxtsetRRR R7R6R R tconfigtyviewtpacktRIGHTtYtLEFTtBOTHtTrueR8R9tbindtHIDE_VIRTUAL_EVENT_NAMEt hide_eventRtHIDE_SEQUENCESt event_addtKEYPRESS_VIRTUAL_EVENT_NAMEtkeypress_eventRtKEYPRESS_SEQUENCEStKEYRELEASE_VIRTUAL_EVENT_NAMEtkeyrelease_eventRtKEYRELEASE_SEQUENCEtLISTUPDATE_SEQUENCEtlistselect_eventRtWINCONFIG_SEQUENCEtwinconfig_eventRtDOUBLECLICK_SEQUENCEtdoubleclick_eventR( Rt comp_listsRItcompleteRt userWantsWint completedR#tacwR RR=tseq((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyt show_window•sd  !             cCs |jƒsdS|j}|j|jƒ|j|jƒ\}}}}|j}|jƒ|jƒ}} |jƒ|jƒ} } |jƒt |t d| |ƒƒ} |j ƒ|} | ||| ksØ|| krå| |7} n | | 8} |j d| | fƒdS(Nis+%d+%d( t is_activeRR4RtbboxRt winfo_widtht winfo_heightt winfo_rootxRtmaxt winfo_rootyRL(RteventttexttxtytcxtcyRst acw_widtht acw_heightt text_widtht text_heighttnew_xtnew_y((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRlÙs   &   cCs|jƒsdS|jƒdS(N(Rvt hide_window(RR}((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyR`îs cCsJ|jƒsdSt|_t|jjƒdƒ}|j|j|ƒdS(Ni(RvR]RR2RR3R$R (RR}R:((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRjós   cCs;t|jjƒdƒ}|j|j|ƒ|jƒdS(Ni(R2RR3R$R R‰(RR}R:((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRnúscsÃ|jƒsdS|j‰t|dƒr4|j}nd}ˆdkrRt|_ntˆƒdks‹ˆd%ks‹|jtkr¼ˆd&kr¼|t @ r¼tˆƒdkrÀ|j |j ˆƒn ˆdkrã|j |j d ƒn}ˆdkr|j |j d ƒnZˆdkr)|j |j d ƒn7t|j ƒdkrL|j ƒdS|j |j d ƒ|j |_ |jjdt|jjƒdƒƒ|jj|j|j ƒƒ|jƒd SˆdkrÖ|j ƒdS|jtkrñˆd'ks|jtkr‘ˆd(kr‘|t @ r‘t|jjƒdƒ}|j|t|j ƒ |j krƒ|jtksl|j rƒ|j |j|ƒn|j ƒdSˆd)kr!| r!t|_t|jjƒdƒ}ˆdkrÛd}nˆdkrýt|jƒd}nâˆd*kr‹|jj|jjƒƒ|jjdƒ}ˆdkrVtd||ƒ}q߈dksht‚tt|jƒd||ƒ}nTˆdkr­td|dƒ}n2ˆdks¿t‚tt|jƒd|dƒ}|jj|ƒ|jj|ƒ|jƒ|j |j|ƒd Sˆdkr‘| r‘|jrxt|jjƒdƒ}|j |j|ƒ|j ƒd St|_t|_dSn.t‡fd†d+Dƒƒr±dS|j ƒdSdS(,Ntmc_stateitTabit underscoret BackSpacetperiodtminust_t.t-iÿÿÿÿtbreaktReturntspacet parenleftt parenrightt bracketleftt bracketrighttslasht backslashtquotedblt apostrophetHometEndtPriortNexttUptDownc3s|]}|ˆkVqdS(N((t.0R%(tkeysym(s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pys `stShifttControltAlttMetatCommandtOption(RŒR(RŽR(RŽR•R–R—R˜R™(sslashR›RœR(RžRŸR R¡R¢R£(R R¡(R¦R§R¨R©RªR«(RvR¥thasattrRŠRRRRRRR$RR‰RRt select_clearR2R3R8R(R9RR R]RtnearestRyR{tAssertionErrorRtany(RR}tstateR:tnewseltjump((R¥s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRds¤            &      #        #         cCs[|jƒsdS|jjdƒ|jjd|jt|jƒfƒkrW|jƒndS(NR s%s+%dc(RvRRIRRRR‰(RR}((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRgjs  +cCs |jdk S(N(RR(R((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRvrscCs|j|j|jƒƒdS(N(R$R-R(R((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRpuscCsL|jƒsdSx!tD]}|jjt|ƒqW|jjt|jƒd|_x!tD]}|jjt |ƒqZW|jjt |j ƒd|_ |jjt t ƒ|jjt |j ƒd|_ |jjt|jƒd|_|jjt|jƒd|_|jjƒd|_|jjƒd|_|jjƒd|_dS(N(RvRaRt event_deleteR_tunbindRRReRcRRfRhRRRiRRRkRR tdestroy(RRt((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyR‰ys0              (t__name__t __module__RR$R(R-R9RuRlR`RjRnRdRgRvRpR‰(((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRs  $ D     j   N(s s ( sss s ss s s s s ((t__doc__tTkintertidlelib.MultiCallRtidlelib.AutoCompleteRRR_RaRcReRfRhRiRkRmR(((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyts