Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/idlelib/AutoCompleteWindow.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c
@s�dZddlTddlmZddlmZmZdZdZdZ	dZ
dZdZdZ
dZdZddd��YZdS(sH
An auto-completion window for IDLE, used by the AutoComplete extension
i�(t*(tMC_SHIFT(tCOMPLETE_FILEStCOMPLETE_ATTRIBUTESs<<autocompletewindow-hide>>s
<FocusOut>s
<ButtonPress>s<<autocompletewindow-keypress>>s<Key>s<Key-BackSpace>s<Key-Return>s	<Key-Tab>s<Key-Up>s
<Key-Down>s
<Key-Home>s	<Key-End>s<Key-Prior>s
<Key-Next>s!<<autocompletewindow-keyrelease>>s<KeyRelease>s<B1-ButtonRelease>s<Configure>s<B1-Double-ButtonRelease>tAutoCompleteWindowcBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�ZRS(cCs�||_d|_|_|_d|_|_d|_d|_d|_	d|_
d|_d|_d|_
d|_|_|_|_|_|_t|_dS(N(twidgettNonetautocompletewindowtlistboxt	scrollbartorigselforegroundtorigselbackgroundtcompletionstmorecompletionstmodetstartt
startindextlasttypedstarttuserwantswindowthideidt
keypressidtlistupdateidtwinconfigidtkeyreleaseidt
doubleclickidtFalsetlastkey_was_tab(tselfR((s0/sys/lib/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((s0/sys/lib/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((s0/sys/lib/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�| 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"((s0/sys/lib/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|jjd|jd|j
�n�|jjd|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	configureRR
tcgetR
RRtENDR t
select_sett_selection_changed(RtcurseltltstselstartR!R"R#titem((s0/sys/lib/python2.7/idlelib/AutoCompleteWindow.pyR9qs2	
	#

#
		cCsJ|\|_|_||_|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
tdd�|_}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-|
�qtW|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 is+10000+10000s!::tk::unsupported::MacWindowStyletstylethelptnoActivatestorienttyscrollcommandtexportselectionR0twhiteR/R.tcommandtsidetfilltexpandN(CRR
RRtindexRtgetRR-R$R(RRRtToplevelRtwm_geometrytwm_overrideredirectttktcallt_wtTclErrort	ScrollbartVERTICALR	tListboxtsetRRR R7R6R
RtconfigtyviewtpacktRIGHTtYtLEFTtBOTHtTrueR8R9tbindtHIDE_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((s0/sys/lib/python2.7/idlelib/AutoCompleteWindow.pytshow_window�sf		
!
	





		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_activeRR4RtbboxRtwinfo_widthtwinfo_heighttwinfo_rootxRtmaxtwinfo_rootyRL(RteventttexttxtytcxtcyRst	acw_widtht
acw_heightt
text_widthttext_heighttnew_xtnew_y((s0/sys/lib/python2.7/idlelib/AutoCompleteWindow.pyRl�s		&

cCs|j�sdS|j�dS(N(Rvthide_window(RR}((s0/sys/lib/python2.7/idlelib/AutoCompleteWindow.pyR`�scCsJ|j�sdSt|_t|jj�d�}|j|j|�dS(Ni(RvR]RR2RR3R$R(RR}R:((s0/sys/lib/python2.7/idlelib/AutoCompleteWindow.pyRj�s
	cCs;t|jj�d�}|j|j|�|j�dS(Ni(R2RR3R$RR�(RR}R:((s0/sys/lib/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
|jd	�n}�dkr|j
|jd
�nZ�dkr)|j
|jd�n7t|j�dkrL|j�dS|j
|jd �|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� |jkr�|jtksl|jr�|j
|j|�n|j�dS�d)kr!|r!t|_t|jj�d�}�dkr�d}n�dkr�|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
parenrighttbracketlefttbracketrighttslasht	backslashtquotedblt
apostrophetHometEndtPriortNexttUptDownc3s|]}|�kVqdS(N((t.0R%(tkeysym(s0/sys/lib/python2.7/idlelib/AutoCompleteWindow.pys	<genexpr>astShifttControltAlttMetatCommandtOption(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�s0/sys/lib/python2.7/idlelib/AutoCompleteWindow.pyRds�		
&

		#
		# 
	
		

cCs[|j�sdS|jjd�|jjd|jt|j�f�krW|j�ndS(NR s%s+%dc(RvRRIRRRR�(RR}((s0/sys/lib/python2.7/idlelib/AutoCompleteWindow.pyRgks
+cCs
|jdk	S(N(RR(R((s0/sys/lib/python2.7/idlelib/AutoCompleteWindow.pyRvsscCs|j|j|j��dS(N(R$R-R(R((s0/sys/lib/python2.7/idlelib/AutoCompleteWindow.pyRpvscCsL|j�sdSx!tD]}|jjt|�qW|jjt|j�d|_x!tD]}|jjt	|�qZW|jjt	|j
�d|_
|jjtt�|jjt|j
�d|_
|jjt|j�d|_|jjt|j�d|_|jj�d|_|jj�d|_|jj�d|_dS(N(RvRaRtevent_deleteR_tunbindRRReRcRRfRhRRRiRRRkRR	tdestroy(RRt((s0/sys/lib/python2.7/idlelib/AutoCompleteWindow.pyR�zs0
	
				
	
	
(t__name__t
__module__RR$R(R-R9RuRlR`RjRnRdRgRvRpR�(((s0/sys/lib/python2.7/idlelib/AutoCompleteWindow.pyRs	 	
	
		$	E					j			N(s
<FocusOut>s
<ButtonPress>(
s<Key>s<Key-BackSpace>s<Key-Return>s	<Key-Tab>s<Key-Up>s
<Key-Down>s
<Key-Home>s	<Key-End>s<Key-Prior>s
<Key-Next>((t__doc__tTkintertidlelib.MultiCallRtidlelib.AutoCompleteRRR_RaRcReRfRhRiRkRmR(((s0/sys/lib/python2.7/idlelib/AutoCompleteWindow.pyt<module>s


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].