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

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


��Qc@s�dZddlZddlZddlZddlmZejejejdZ	ejejdZ
edd�\ZZ
ddlmZdd	lmZddlZejZejr�eej7Znd
d
d��YZdS(s�AutoComplete.py - An IDLE extension for automatically completing names.

This extension can complete either attribute names of file names. It can pop
a window with all available names, for the user to select from.
i�N(tidleConfs._~#$:-t_ii(tAutoCompleteWindow(tHyperParsertAutoCompletecBs�eZddgfgZejddddddd	�Zdd
�Zd�Zdd�Z	d
�Z
d�Zd�Zd�Z
d�Zdd�Zd�Zd�ZRS(teditsShow Completionss<<force-open-completions>>t
extensionsRt	popupwaitttypetinttdefaulticCsD||_|dkrdS|j|_d|_d|_d|_dS(N(teditwintNonettexttautocompletewindowt_delayed_completion_idt_delayed_completion_index(tselfR((s*/sys/lib/python2.7/idlelib/AutoComplete.pyt__init__)s			cCstj|j�S(N(RR
(R((s*/sys/lib/python2.7/idlelib/AutoComplete.pyt_make_autocomplete_window6scCs&|jr"|jj�d|_ndS(N(Rthide_windowR(Rtevent((s*/sys/lib/python2.7/idlelib/AutoComplete.pyt_remove_autocomplete_window9s	
cCs|jttt�dS(sqHappens when the user really wants to open a completion list, even
        if a function call is needed.
        N(topen_completionstTruetFalse(RR((s*/sys/lib/python2.7/idlelib/AutoComplete.pytforce_open_completions_event>scCs`|jjd�}|dkr7|jtttt�n%|tkr\|jtttt�ndS(s�Happens when it would be nice to open a completion list, but not
        really necessary, for example after an dot, so function
        calls won't be made.
        s	insert-1ct.N(R
tgett_open_completions_laterRtCOMPLETE_ATTRIBUTEStSEPStCOMPLETE_FILES(RRtlastchar((s*/sys/lib/python2.7/idlelib/AutoComplete.pyttry_open_completions_eventDs
cCsht|d�r|jrdS|jrE|jj�rE|jj�dS|jttt�}|rddSdS(s�Happens when the user wants to complete his word, and if necessary,
        open a completion list after that (if there is more than one
        completion)
        tmc_stateNtbreak(thasattrR#Rt	is_activetcompleteRRR(RRtopened((s*/sys/lib/python2.7/idlelib/AutoComplete.pytautocomplete_eventQs
cGs_|jjd�|_|jdk	r:|jj|j�n|jj|j|j|�|_dS(Ntinsert(	R
tindexRRRtafter_canceltafterRt_delayed_open_completions(Rtargs((s*/sys/lib/python2.7/idlelib/AutoComplete.pyRas
cGs9d|_|jjd�|jkr(dS|j|�dS(NR*(RRR
R+RR(RR/((s*/sys/lib/python2.7/idlelib/AutoComplete.pyR.is	cCse|jdk	r.|jj|j�d|_nt|jd�}|jjdd�}t|�}}|j�r|s�|t	kr|j
�t	}x(|r�||dtkr�|d8}q�W|||!}	|}x,|r||dttkr|d8}q�W|||!}
n�j
�r�s0|tkr�j
�t}x(|rj||dtkrj|d8}qCW|||!}	|r�|ddkr�jdt|�|d�|j�}
|
s�r�
jd�dkr�Sq�}
ndS|r|
r|	rdS|j|
|�}|d
s,dS|j�|_|jj|dt|	�|||�tS(sXFind the completions and create the AutoCompleteWindow.
        Return True if successful (no syntax error or so found).
        if complete is True, then if there's nothing to complete and no
        start of completion, won't open completions and return False.
        If mode is given, will open a completion list only in this mode.
        R*sinsert linestartiRs
insert-%dct(i�Nti(RRR
R,RRRtlentis_in_stringR RtFILENAME_CHARSRt
is_in_codeRtID_CHARSt	set_indextget_expressiontfindtfetch_completionsRRtshow_windowR(Rt	evalfuncsR'tuserWantsWintmodethptcurlinetitjt
comp_startt	comp_whatt
comp_lists((s*/sys/lib/python2.7/idlelib/AutoComplete.pyRosT

!

	

c
Cs&y|jjjjj}Wn
d	}nX|rK|jdd||fi�S|tkrr|dkr�j	j
�}|jtjj	�t
d|�}|j�d|kr�tt
d|��}qog|D]}|d dkr�|^q�}q	yp|j|�}t|�}|j�d|kr4t|j�}n)g|D]}|d dkr;|^q;}Wq	ggfSXn�|tkr	|dkr�d}nyXtjj|�}	tj|	�}|j�g|D]}|d dkr�|^q�}Wq	tk
rggfSXn|s|}n||fSd	S(
sOReturn a pair of lists of completions for something. The first list
        is a sublist of the second. Both are sorted.

        If there is a Python subprocess, get the comp. list there.  Otherwise,
        either fetch_completions() is running in the subprocess itself or it
        was called in an IDLE EditorWindow before any script had been run.

        The subprocess environment is that of the most recently run script.  If
        two unrelated modules are being edited some calltips in the current
        module may be inoperative if the module was not the last to run.
        texectget_the_completion_listR1sdir()t__all__iRRN(RtflisttpyshelltinterptrpccltRt
remotecallRt__main__t__dict__tcopytupdatet__builtins__tevaltsorttsortedt
get_entitytdirRHR tostpatht
expandusertlistdirtOSError(
RtwhatR>RLt	namespacetbigltsmallltstentitytexpandedpath((s*/sys/lib/python2.7/idlelib/AutoComplete.pyR:�sL

,
-	
-
	cCs,tjj�}|jtj�t||�S(sALookup name in a namespace spanning sys.modules and __main.dict__(tsystmodulesRPRQRNRORS(RtnameR^((s*/sys/lib/python2.7/idlelib/AutoComplete.pyRV�s(sShow Completionss<<force-open-completions>>N(t__name__t
__module__tmenudefsRt	GetOptionRRRRRRR"R)RR.RR:RV(((s*/sys/lib/python2.7/idlelib/AutoComplete.pyRs
			
			7	9i((t__doc__RXRdtstringtidlelib.configHandlerRt
ascii_letterstdigitstcurdirR4R6trangeRR tidlelibRtidlelib.HyperParserRRNtsepRtaltsepR(((s*/sys/lib/python2.7/idlelib/AutoComplete.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].