� {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 stAutoCompleteWindowcBs�eZd�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}q�W|| }|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*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 bstShifttControltAlttMetatCommandtOption(R�R�(R�R�(R�R�R�R�R�R�(R�R�R�R�(R�R�R�R�R�R�(R�R�(R�R�R�R�R�R�(RwR�thasattrR�RRRRRRR$RR�RRt select_clearR2R3R8R(R9RR R]RtnearestRzR|tAssertionErrorRtany(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