3 § fl$ã@s¶dZddlZddlZddlZeddƒ\ZZddlmZddl m Z ddl m Z ddl Z ejejdZejZejr|eej7ZGd d „d ƒZejƒed kr²dd lmZed dd�dS)z”Complete either attribute names or file names. Either on demand or after a user-selected delay after a key character, pop up a list of candidates. éNéé)Úautocomplete_w)ÚidleConf)Ú HyperParserÚ_c@sveZdZddd„Zedd„ƒZdd„Zddd „Zd d „Zd d „Z dd„Z dd„Z dd„Z ddd„Z dd„Zdd„ZdS)Ú AutoCompleteNcCs,||_|dk r(|j|_d|_d|_d|_dS)N)ÚeditwinÚtextÚautocompletewindowÚ_delayed_completion_idÚ_delayed_completion_index)Úselfr ©rú9/opt/alt/python36/lib64/python3.6/idlelib/autocomplete.pyÚ__init__s zAutoComplete.__init__cCstjdddddd�|_dS)NÚ extensionsrÚ popupwaitÚintr)ÚtypeÚdefault)rZ GetOptionr)ÚclsrrrÚreload)szAutoComplete.reloadcCs tj|jƒS)N)rZAutoCompleteWindowr )rrrrÚ_make_autocomplete_window.sz&AutoComplete._make_autocomplete_windowcCs|jr|jjƒd|_dS)N)r Z hide_window)rÚeventrrrÚ_remove_autocomplete_window1s z(AutoComplete._remove_autocomplete_windowcCs|jdddƒdS)zqHappens when the user really wants to open a completion list, even if a function call is needed. TFÚbreak)Úopen_completions)rrrrrÚforce_open_completions_event6sz)AutoComplete.force_open_completions_eventcCsB|jjdƒ}|dkr&|jdddtƒn|tkr>|jdddtƒdS)z¥Happens when it would be nice to open a completion list, but not really necessary, for example after a dot, so function calls won't be made. z insert-1cÚ.FN)r ÚgetÚ_open_completions_laterÚCOMPLETE_ATTRIBUTESÚSEPSÚCOMPLETE_FILES)rrZlastcharrrrÚtry_open_completions_event=s   z'AutoComplete.try_open_completions_eventcCsdt|dƒr|js$|jjddƒjƒ r(dS|jrF|jjƒrF|jjƒdS|jdddƒ}|r\dSdSdS)z¥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) Úmc_statezinsert linestartÚinsertNrFT) Úhasattrr&r r Ústripr Z is_activeÚcompleter)rrZopenedrrrÚautocomplete_eventJs zAutoComplete.autocomplete_eventcGsD|jjdƒ|_|jdk r&|jj|jƒ|jj|j|jf|žŽ|_dS)Nr')r Úindexr r Ú after_cancelÚafterrÚ_delayed_open_completions)rÚargsrrrr![s  z$AutoComplete._open_completions_latercGs&d|_|jjdƒ|jkr"|j|ŽdS)Nr')r r r,r r)rr0rrrr/csz&AutoComplete._delayed_open_completionsc Csþ|jdk r|jj|jƒd|_t|jdƒ}|jjddƒ}t|ƒ}}|jƒrÌ| sZ|tkrÌ|j ƒt}x$|rŠ||ddt krŠ|d8}qhW|||…} |}x |r¼||ddkr¼|d8}qžW|||…} nÖ|j ƒoà| sä|t k�rž|j ƒt }x:|�r*||dt k�s t||dƒdk�r*|d8}qòW|||…} |�r˜||ddk�r˜|jdt|ƒ|dƒ|jƒ} | �s’| �rœ| jd ƒd k�rœdSnd } ndS|�r¼| �r¼| �r¼dS|j| |ƒ} | d �sÖdS|jƒ|_|jj| dt| ƒ|||ƒ S) aXFind 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. Nr'zinsert linestartrz'"érz insert-%dcú(Úréÿÿÿÿ)r r r-rr r ÚlenZ is_in_stringr$rr#Z is_in_coder"ÚID_CHARSÚordZ set_indexZget_expressionÚfindÚfetch_completionsrr Z show_window) rZ evalfuncsr*Z userWantsWinÚmodeZhpZcurlineÚiÚjZ comp_startZ comp_whatZ comp_listsrrrrhsN      0      zAutoComplete.open_completionsc Csjy|jjjjj}Wnd}YnX|r<|jdd||fiƒS|tkrð|dkržtjj ƒ}|j tj jƒt d|ƒ}|j ƒd|krŽtt d|ƒƒ}qîdd„|Dƒ}nPy@|j|ƒ}t|ƒ}|j ƒd|krÎt|jƒ}nd d„|Dƒ}WnggfSnd|tk�rT|dk�rd }y0tjj|ƒ}tj|ƒ}|j ƒd d„|Dƒ}Wntk �rRggfSX|�s^|}||fSdS) aOReturn 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. NÚexecZget_the_completion_listr3zdir()Ú__all__cSs g|]}|dd…dkr|‘qS)Nrrr)Ú.0Úsrrrú Àsz2AutoComplete.fetch_completions..cSs g|]}|dd…dkr|‘qS)Nrrr)r?r@rrrrAÉsrcSs g|]}|dd…dkr|‘qS)Nrrr)r?r@rrrrAÔs)r ZflistZpyshellZinterpÚrpccltZ remotecallr"Ú__main__Ú__dict__ÚcopyÚupdateÚ __builtins__ÚevalÚsortÚsortedÚ get_entityÚdirr>r$ÚosÚpathÚ expanduserÚlistdirÚOSError) rZwhatr:rBÚ namespaceZbiglZsmalllZentityZ expandedpathrrrr9£sL             zAutoComplete.fetch_completionscCs tjjƒ}|jtjƒt||ƒS)zALookup name in a namespace spanning sys.modules and __main.dict__)ÚsysÚmodulesrErFrCrDrH)rÚnamerRrrrrKÜs  zAutoComplete.get_entity)N)N)N)Ú__name__Ú __module__Ú __qualname__rÚ classmethodrrrrr%r+r!r/rr9rKrrrrrs    ;9rrC)Úmainz#idlelib.idle_test.test_autocomplete)Ú verbosityé)Ú__doc__rMÚstringrSÚranger"r$ZidlelibrZidlelib.configrZidlelib.hyperparserrrCZ ascii_lettersZdigitsr6Úsepr#ÚaltseprrrVZunittestrZrrrrÚs$    H