3  fl$@sdZddlZddlZddlZedd\ZZddlmZddl m Z ddl m Z ddl Z ejejdZejZejr|eej7ZGd d d Zejed krdd lmZed dddS)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)autocomplete_w)idleConf) HyperParser_c@sveZdZdddZeddZddZddd Zd d Zd d Z ddZ ddZ ddZ dddZ ddZddZdS) AutoCompleteNcCs,||_|dk r(|j|_d|_d|_d|_dS)N)editwintextautocompletewindow_delayed_completion_id_delayed_completion_index)selfr r9/opt/alt/python36/lib64/python3.6/idlelib/autocomplete.py__init__s zAutoComplete.__init__cCstjdddddd|_dS)N extensionsr popupwaitintr)typedefault)rZ GetOptionr)clsrrrreload)szAutoComplete.reloadcCs tj|jS)N)rZAutoCompleteWindowr )rrrr_make_autocomplete_window.sz&AutoComplete._make_autocomplete_windowcCs|jr|jjd|_dS)N)r Z hide_window)reventrrr_remove_autocomplete_window1s z(AutoComplete._remove_autocomplete_windowcCs|jddddS)zqHappens when the user really wants to open a completion list, even if a function call is needed. TFbreak)open_completions)rrrrrforce_open_completions_event6sz)AutoComplete.force_open_completions_eventcCsB|jjd}|dkr&|jdddtn|tkr>|jdddtdS)zHappens 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_laterCOMPLETE_ATTRIBUTESSEPSCOMPLETE_FILES)rrZlastcharrrrtry_open_completions_event=s   z'AutoComplete.try_open_completions_eventcCsdt|dr|js$|jjddj r(dS|jrF|jjrF|jjdS|jddd}|r\dSdSdS)zHappens 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 linestartinsertNrFT) hasattrr&r r stripr Z is_activecompleter)rrZopenedrrrautocomplete_eventJs zAutoComplete.autocomplete_eventcGsD|jjd|_|jdk r&|jj|j|jj|j|jf||_dS)Nr')r indexr r after_cancelafterr_delayed_open_completions)rargsrrrr![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|jd|_t|jd}|jjdd}t|}}|jr| sZ|tkr|j t}x$|r||ddt kr|d8}qhW|||} |}x |r||ddkr|d8}qW|||} n|j o| s|t kr|j t }x:|r*||dt ks t||ddkr*|d8}qW|||} |r||ddkr|jdt||d|j} | s| r| jd d krdSnd } ndS|r| r| rdS|j| |} | d sdS|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_CHARSordZ set_indexZget_expressionfindfetch_completionsrr Z show_window) rZ evalfuncsr*Z userWantsWinmodeZhpZcurlineijZ comp_startZ comp_whatZ comp_listsrrrrhsN      0      zAutoComplete.open_completionsc Csjy|jjjjj}Wnd}YnX|r<|jdd||fiS|tkr|dkrtjj }|j tj jt d|}|j d|krtt d|}qdd|D}nPy@|j|}t|}|j d|krt|j}nd d|D}WnggfSnd|tkrT|dkrd }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. NexecZget_the_completion_listr3zdir()__all__cSs g|]}|dddkr|qS)Nrrr).0srrr sz2AutoComplete.fetch_completions..cSs g|]}|dddkr|qS)Nrrr)r?r@rrrrAsrcSs g|]}|dddkr|qS)Nrrr)r?r@rrrrAs)r ZflistZpyshellZinterprpccltZ remotecallr"__main____dict__copyupdate __builtins__evalsortsorted get_entitydirr>r$ospath expanduserlistdirOSError) rZwhatr:rB namespaceZbiglZsmalllZentityZ expandedpathrrrr9sL             zAutoComplete.fetch_completionscCs tjj}|jtjt||S)zALookup name in a namespace spanning sys.modules and __main.dict__)sysmodulesrErFrCrDrH)rnamerRrrrrKs  zAutoComplete.get_entity)N)N)N)__name__ __module__ __qualname__r classmethodrrrrr%r+r!r/rr9rKrrrrrs    ;9rrC)mainz#idlelib.idle_test.test_autocomplete) verbosity)__doc__rMstringrSranger"r$ZidlelibrZidlelib.configrZidlelib.hyperparserrrCZ ascii_lettersZdigitsr6sepr#altseprrrVZunittestrZrrrrs$    H