o =?hc@sdZddlZddlZddlZddlZddlZddlZddlmZddl m Z GdddZ ddZ d Z d Zd Zed Zd ZdZddZedkrVddlmZeddddSdS)zPop up a reminder of how to call a function. Call Tips are floating windows which display function, class, and method parameter and docstring information when you type an opening parenthesis, and which disappear when you type a closing parenthesis. N) calltip_w) HyperParserc@sXeZdZdddZddZddZddd Zd d Zd d ZddZ ddZ ddZ dS)CalltipNcCs2|dur d|_dS||_|j|_d|_|j|_dSN)editwintextactive_calltip_make_tk_calltip_window_calltip_window)selfrr 6/opt/alt/python310/lib64/python3.10/idlelib/calltip.py__init__s   zCalltip.__init__cCs d|_dSr)r r r r r closes z Calltip.closecCs t|jSr)rZ CalltipWindowrrr r r r s zCalltip._make_tk_calltip_windowcCs|jr |jd|_dSdSr)rZhidetipr Zeventr r r remove_calltip_window$s  zCalltip.remove_calltip_windowcC|ddS)z9The user selected the menu entry or hotkey, open the tip.Tbreak open_calltiprr r r force_open_calltip_event)s z Calltip.force_open_calltip_eventcCr)zHappens when it would be nice to open a calltip, but not really necessary, for example after an opening bracket, so function calls won't be made. FNrrr r r try_open_calltip_event.szCalltip.try_open_calltip_eventcCs$|jr|jjr|ddSdSdS)NF)rZ tipwindowrrr r r refresh_calltip_event5szCalltip.refresh_calltip_eventcCst|jd}|d}|s|dS|jr0tt|dd\}}||f|jj|jj fkr0dS| |dz| }Wn t yHd}Ynw|sMdS||s\| ddkr\dS||}|sedS||_|j||d|ddS)zMaybe close an existing calltip and maybe open a new calltip. Called from (force_open|try_open|refresh)_calltip_event functions. insert(Nr.)rrZget_surrounding_bracketsrrmapintsplitZ parenlineZparencolZ set_indexZget_expression ValueErrorfind fetch_tipr Zshowtip)r Z evalfuncsZhpZ sur_parenZ opener_lineZ opener_col expressionargspecr r r r9s6      zCalltip.open_calltipcCsLz |jjjjj}Wn tyd}Ynw|r |dd|fiStt|S)aDReturn the argument list and docstring of a function or class. If there is a Python subprocess, get the calltip there. Otherwise, either this fetch_tip() is running in the subprocess or it was called in an IDLE running without the subprocess. 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. To find methods, fetch_tip must be fed a fully qualified name. NexecZget_the_calltip) rZflistZpyshellZinterprpccltAttributeErrorZ remotecall get_argspec get_entity)r r%r(r r r r$ls  zCalltip.fetch_tipr) __name__ __module__ __qualname__rrr rrrrrr$r r r r rs    3rcCs:|ritjtj}zt||WStyYdSwdS)zwReturn the object corresponding to expression evaluated in a namespace spanning sys.modules and __main.dict__. N)sysmodules__main____dict__eval BaseException)r% namespacer r r r+s  r+Uz z(?<=\()\w*\,?\s*zSee source or doczinvalid method signaturec CsFz|j}Wn tyYdSwt|tjr|n|}z tt|}Wn%tyH}zt|}| t rs,  s 1