B ãxácú"ã@sÞdZddlZddlZddlZddlZd\ZZddlmZddl m Z ddl m Z dZ dZd d d efZd d d efZejejd Zej›ejr’ejnd ›Zd e›ZGd d„dƒZe ¡edkrÚddlmZeddddS)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)ré)Úautocomplete_w)ÚidleConf)Ú HyperParser)TFTN)FTTNFÚ_ÚÚ.c@sneZdZddd„Zedd„ƒZdd„Zddd „Zd d „Zd d „Z ddd„Z dd„Z dd„Z dd„Z dd„ZdS)Ú AutoCompleteNcCs,||_|dk r|j|_d|_d|_d|_dS)N)ÚeditwinÚtextÚautocompletewindowÚ_delayed_completion_idÚ_delayed_completion_index)Úselfr ©rú9/opt/alt/python37/lib64/python3.7/idlelib/autocomplete.pyÚ__init__!s zAutoComplete.__init__cCstjdddddd|_dS)NÚ extensionsr Ú popupwaitÚintr)ÚtypeÚdefault)rZ GetOptionr)ÚclsrrrÚreload,szAutoComplete.reloadcCs t |j¡S)N)rZAutoCompleteWindowr )rrrrÚ_make_autocomplete_window1sz&AutoComplete._make_autocomplete_windowcCs|jr|j ¡d|_dS)N)r Z hide_window)rÚeventrrrÚ_remove_autocomplete_window4s z(AutoComplete._remove_autocomplete_windowcCs| t¡dS)zA(^space) Open completion list, even if a function call is needed.Úbreak)Úopen_completionsÚFORCE)rrrrrÚforce_open_completions_event9s z)AutoComplete.force_open_completions_eventcCs^t|dƒr|js"|j dd¡ ¡s&dS|jrD|j ¡rD|j ¡dS| t ¡}|rVdSdSdS)z5(tab) Complete word or open list if multiple options.Úmc_statezinsert linestartÚinsertNr) Úhasattrr!r ÚgetÚstripr Z is_activeÚcompleterÚTAB)rrZopenedrrrÚautocomplete_event>s  zAutoComplete.autocomplete_eventcCsd|j d¡}|tkr`|dkr tnt}|j d¡|_|jdk rJ|j |j¡|j  |j |j |¡|_dS)z7(./) Open completion list after pause with no movement.z insert-1crr"N) r r$ÚTRIGGERSÚTRY_AÚTRY_FÚindexrr Ú after_cancelZafterrÚ_delayed_open_completions)rrZlastcharÚargsrrrÚtry_open_completions_eventLs  z'AutoComplete.try_open_completions_eventcCs&d|_|j d¡|jkr"| |¡dS)z)Call open_completions if index unchanged.Nr")r r r,rr)rr/rrrr.Wsz&AutoComplete._delayed_open_completionsc Cs|\}}}}|jdk r*|j |j¡d|_t|jdƒ}|j dd¡}t|ƒ}} | ¡rÖ|rd|tkrÖ|  ¡t}x$|r”||ddt kr”|d8}qrW||| …} |} x |rÆ||ddkrÆ|d8}q¨W||| …} nÒ|  ¡r¤|rî|t kr¤|  ¡t }x:|r4||dt ks*t||dƒdkr4|d8}qüW||| …} |rž||ddkrž| dt|ƒ|d¡| ¡} | r˜|s¢|  d ¡d kr¢dSnd } ndS|r¾| s¾| s¾dS| | |¡} | d sØdS| ¡|_|j | 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ú(éÿÿÿÿrr)r r r-rr r$ÚlenZ is_in_stringÚFILESrÚSEPSZ is_in_codeÚATTRSÚID_CHARSÚordZ set_indexZget_expressionÚfindÚfetch_completionsrr Z show_window) rr/Z evalfuncsr&ZwantwinÚmodeZhpZcurlineÚiÚjZ comp_startZ comp_whatZ comp_listsrrrr]sP       0      zAutoComplete.open_completionsc Cs`y|jjjjj}Wnd}YnX|r<| dd||fi¡S|tkræ|dkr”tjj tj –}t d|ƒ}|  ¡d|kr„t t d|ƒƒ}qädd„|Dƒ}nPy@|  |¡}t|ƒ}|  ¡d|krÄt |jƒ}nd d„|Dƒ}WnggfSnd|tkrJ|dkrþd }y0tj |¡}t |¡}|  ¡d d„|Dƒ}Wntk rHggfSX|sT|}||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_listrzdir()Ú__all__cSs g|]}|dd…dkr|‘qS)Nrrr)Ú.0Úsrrrú ¶sz2AutoComplete.fetch_completions..cSs g|]}|dd…dkr|‘qS)Nrrr)rArBrrrrC¿srcSs g|]}|dd…dkr|‘qS)Nrrr)rArBrrrrCÊs)r ZflistZpyshellZinterpÚrpccltZ remotecallr7Ú__main__Ú __builtins__Ú__dict__ÚevalÚsortÚsortedÚ get_entityÚdirr@r5ÚosÚpathÚ expanduserÚlistdirÚOSError) rZwhatr<rDÚ namespaceZbiglZsmalllZentityZ expandedpathrrrr;™sL            zAutoComplete.fetch_completionscCst|tjtj–ƒS)zBLookup name in a namespace spanning sys.modules and __main.dict__.)rHÚsysÚmodulesrErG)rÚnamerrrrKÒszAutoComplete.get_entity)N)N)N)Ú__name__Ú __module__Ú __qualname__rÚ classmethodrrrr r(r0r.rr;rKrrrrr s   <9r rE)Úmainz#idlelib.idle_test.test_autocompleteé)Ú verbosity)Ú__doc__rErMÚstringrSr7r5ZidlelibrZidlelib.configrZidlelib.hyperparserrrr'r*r+Z ascii_lettersZdigitsr8ÚsepÚaltsepr6r)r rrVZunittestrZrrrrÚs*      9