a XC?h#@sdZddlZddlZddlZddlZddlZd\ZZddlm Z ddl m Z ddl m Z dZdZd d d efZd d d efZejejd Zejejrejnd Zd eZGd ddZeedkrddlmZeddddS)zComplete 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@sneZdZdddZeddZddZddd Zd d Zd d Z dddZ ddZ ddZ ddZ ddZdS) AutoCompleteNcCs,||_|dur|j|_d|_d|_d|_dSN)editwintextautocompletewindow_delayed_completion_id_delayed_completion_index)selfr r9/opt/alt/python39/lib64/python3.9/idlelib/autocomplete.py__init__"s zAutoComplete.__init__cCstjdddddd|_dS)N extensionsr popupwaitintr)typedefault)rZ GetOptionr)clsrrrreload-s zAutoComplete.reloadcCs t|jSr )rZAutoCompleteWindowr )rrrr_make_autocomplete_window2sz&AutoComplete._make_autocomplete_windowcCs|jr|jd|_dSr )r Z hide_windowreventrrr_remove_autocomplete_window5s z(AutoComplete._remove_autocomplete_windowcCs|tdS)zA(^space) Open completion list, even if a function call is needed.break)open_completionsFORCErrrrforce_open_completions_event:s z)AutoComplete.force_open_completions_eventcCs^t|dr|js"|jdds&dS|jrD|jrD|jdS|t }|rVdSdSdS)z5(tab) Complete word or open list if multiple options.mc_stateinsert linestartinsertNr) hasattrr#r getstripr Z is_activecompleter TAB)rrZopenedrrrautocomplete_event?s  zAutoComplete.autocomplete_eventcCsd|jd}|tvr`|dkr tnt}|jd|_|jdurJ|j|j|j |j |j ||_dS)z7(./) Open completion list after pause with no movement.z insert-1crr%N) r r'TRIGGERSTRY_ATRY_Findexrr after_cancelZafterr_delayed_open_completions)rrZlastcharargsrrrtry_open_completions_eventMs   z'AutoComplete.try_open_completions_eventcCs&d|_|jd|jkr"||dS)z)Call open_completions if index unchanged.Nr%)rr r/rr )rr2rrrr1Xsz&AutoComplete._delayed_open_completionsc Cs|\}}}}|jdur*|j|jd|_t|jd}|jdd}t|}} |r|rd|tkr| t}|r||ddt vr|d8}qp||| } |} |r||ddvr|d8}q||| } n| r|r|t kr| t }|r*||dt vs t||ddkr*|d8}q||| } |r||ddkr|dt||d|} | r|s| d d krdSnd } ndS|r| s| sdS|| |} | d sdS||_|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%r$rz'"rz insert-%dc(rr)rr r0rr r'lenZ is_in_stringFILESrSEPSZ is_in_codeATTRSID_CHARSordZ set_indexZget_expressionfindfetch_completionsrr Z show_window) rr2Z evalfuncsr)ZwantwinmodeZhpZcurlineijZ comp_startZ comp_whatZ comp_listsrrrr ^sX       .       zAutoComplete.open_completionsc Csz|jjjjj}Wnd}Yn0|r<|dd||fiS|tkr |dkritjj tj }t d|}ddt j D}| ||d|vrtt d|}nd d |D}nVz@||}t|}|d|vrt|j}nd d |D}WnggfYS0nf|tkrr|dkr$d }z0tj|} t| }|d d |D}WntypggfYS0|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. NexecZget_the_completion_listrzdir()css|]}|dvr|VqdS)>TrueFalseNoneNr.0srrr sz1AutoComplete.fetch_completions..__all__cSs g|]}|dddkr|qSNrrrrFrrr z2AutoComplete.fetch_completions..cSs g|]}|dddkr|qSrKrrFrrrrLrMrcSs g|]}|dddkr|qS)NrrrrFrrrrLrM)r ZflistZpyshellZinterprpccltZ remotecallr:__main__ __builtins____dict__evalkeywordkwlistextendsortsorted get_entitydirrJr8ospath expanduserlistdirOSError) rZwhatr?rN namespaceZbiglkwdsZsmalllZentityZ expandedpathrrrr>sT            zAutoComplete.fetch_completionscCst|itjtjS)zBLookup name in a namespace spanning sys.modules and __main.dict__.)rRsysmodulesrOrQ)rnamerrrrXszAutoComplete.get_entity)N)N)N)__name__ __module__ __qualname__r classmethodrrrr"r+r3r1r r>rXrrrrr s    <s,      <