ó {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   #  #    cCsT|\|_|_||_|jj|ƒ|_|jj|jdƒ|_|râ|j|jƒ}|j}|j |ƒ|j |ƒ}|j||krâ|t |jƒdksÕ|j|dt |ƒ |krâ||kSn||_ |j|_ t|jƒ|_} | jdƒ| jdƒy#| jjdd| jddƒWntk r]nXt| dtƒ|_} t| d | jd td d ƒ|_} x!|jD]} | jt| ƒq©W| jd ƒ|_ | jdƒ|_!| j"d| j#ƒ| j$dt%dt&ƒ| j$dt'dt(dt)ƒ| j*ƒ|jj+|j |jƒƒ|j,ƒ|jj-t.|j/ƒ|_0x!t1D]} |jj2t.| ƒq~W|jj-t3|j4ƒ|_5x!t6D]} |jj2t3| ƒq½W|jj-t7|j8ƒ|_9|jj2t7t:ƒ| j-t;|j<ƒ|_=| j-t>|j?ƒ|_@| j-tA|jBƒ|_CdS(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 is +10000+10000s!::tk::unsupported::MacWindowStyletstylethelpt noActivatestorienttyscrollcommandtexportselectionR0twhiteR/R.tcommandtsidetfilltexpandN(DR R RRtindexRtgetRR-R$R(RRRtToplevelRt wm_geometrytwm_overrideredirectttktcallt_wtTclErrort ScrollbartVERTICALR tListboxtsetRRR R7R6R R tconfigtyviewtpacktRIGHTtYtLEFTtBOTHtTruetliftR8R9tbindtHIDE_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 completedRR#tacwR RR=tseq((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyt show_window•sh   !               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(RteventttexttxtytcxtcyRtt acw_widtht acw_heightt text_widtht text_heighttnew_xtnew_y((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRmÛs   &   cCs|jƒsdS|jƒdS(N(Rwt hide_window(RR~((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRaðs cCsJ|jƒsdSt|_t|jjƒdƒ}|j|j|ƒdS(Ni(RwR]RR2RR3R$R (RR~R:((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRkõs   cCs;t|jjƒdƒ}|j|j|ƒ|jƒdS(Ni(R2RR3R$R RŠ(RR~R:((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRoü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*kry|jj|jjƒƒ|jjdƒ}ˆdkrVtd||ƒ}q»tt|jƒd||ƒ}nBˆdkr›td|dƒ}n tt|jƒd|dƒ}|jj|ƒ|jj|ƒ|jƒ|j |j|ƒd Sˆdkrm| rm|jrTt|jjƒdƒ}|j |j|ƒ|j ƒd St|_t|_dSn.t‡fd†d+DƒƒrdS|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 bstShifttControltAlttMetatCommandtOption(RRŽ(RR(RR–R—R˜R™Rš(R›RœRRž(RŸR R¡R¢R£R¤(R¡R¢(R§R¨R©RªR«R¬(RwR¦thasattrR‹RRRRRRR$RRŠRRt select_clearR2R3R8R(R9RR R]RtnearestRzR|Rtany(RR~tstateR:tnewseltjump((R¦s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRes             &      #        #         cCs[|jƒsdS|jjdƒ|jjd|jt|jƒfƒkrW|jƒndS(NR s%s+%dc(RwRRIRRRRŠ(RR~((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRhls  +cCs |jdk S(N(RR(R((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRwtscCs|j|j|jƒƒdS(N(R$R-R(R((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRqwscCsL|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(RwRbRt event_deleteR`tunbindRRRfRdRRgRiRRRjRRRlRR tdestroy(RRu((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRŠ{s0              (t__name__t __module__RR$R(R-R9RvRmRaRkRoReRhRwRqRŠ(((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyRs  $ F     j   N(s s ( sss s ss s s s s ((t__doc__tTkintertidlelib.MultiCallRtidlelib.AutoCompleteRRR`RbRdRfRgRiRjRlRnR(((s2/usr/lib64/python2.7/idlelib/AutoCompleteWindow.pyts