3  f@sddlZy ddlTWn*ek r>edejdedYnXejdkry ddlZdZej dj eWnee e fk rYnXddl jZedkreatjdd lmZetejd d etd eddd lmZddlZddlZddlZddlmZddlZddlZddlZddl m!Z!ddl"Z"ddl#Z#ddl$Z$ddl%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+ddl*m,Z,ddl-m.Z.m/Z/ddl0m1Z1ddl2m3Z3ddl*m4Z4ddlm5Z5m6Z6m7Z7ddl8m9Z9dZ:dZ;ejaddZ?e?ddej@fd d!ZAeAe_@Gd"d#d#e.ZBGd$d%d%e1ZCGd&d'd'e'ZDGd(d)d)e9ZEGd*d+d+e4jFZGGd,d-d-eZHGd.d/d/e3ZId0d1ZJd2ZKd3d4ZLeMd5krejNd5ejNd6<eLe?d7dS)9N)*zJ** IDLE can't import Tkinter. Your Python may not be configured for Tk. **)fileZwin32Zshcoreg!@) fix_scalingzIdle Cannot Startz"Idle requires tcl/tk 8.5+, not %s.)parent)InteractiveInterpreter)python_version) TextWrapper)ColorDelegator)idleConf)debugger) debugger_r) EditorWindow fixwordbreaks)FileList) OutputWindow)rpc)idle_formatwarningPseudoInputFilePseudoOutputFile) UndoDelegatorz 127.0.0.1cCsP|dkr t}y&|jt|||||d|jdWnttfk rJYnXdS)aShow Idle-format warning (after replacing warnings.showwarning). The differences are the formatter called, the file=None replacement, which can be None, the capture of the consequence AttributeError, and the output of a hard-coded prompt. N)linez>>> )warning_streamwriterAttributeErrorOSError)messagecategoryfilenamelinenorrr 4/opt/alt/python36/lib64/python3.6/idlelib/pyshell.pyidle_showwarningCsr"cCs0|rtdkr,tjatt_ntdk r,tt_dadS)z>Replace warning.showwarning with idle_showwarning, or reverse.N)_warnings_showwarningwarnings showwarningr")Zcapturer r r!capture_warningsVsr&TcCs\tj}i}x:t|D].}|dd|dddkr|j|||<qW|||j|dS)aoExtend linecache.checkcache to preserve the entries Rather than repeating the linecache code, patch it to save the entries, call the original linecache.checkcache() (skipping them), and then restore the saved entries. orig_checkcache is bound at definition time to the original method, allowing it to be patched. Nrz<>) linecachecachelistpopupdate)rZorig_checkcacher)savekeyr r r!extended_linecache_checkcachees r/c@s~eZdZdZddZd'd(d)d*d+d,gZd-ddZddZd.ddZd/ddZ ddZ ddZ dd Z d!d"Z d#d$Zd%d&Zd S)0PyShellEditorWindowz6Regular text edit window in IDLE, supports breakpointscGsg|_tj|f||jjd|j|jjd|j|jjd|jjt j j t j d|_|jj|fdd}|jj||jjr|j|jdS)Nz<>z<>z<>zbreakpoints.lstcSs|j|dS)N)restore_file_breaks)Zold_hookselfr r r!filename_changed_hooksz;PyShellEditorWindow.__init__..filename_changed_hook) breakpointsr__init__textbindset_breakpoint_hereclear_breakpoint_hereflist open_shellospathjoinr ZuserdirbreakpointPathioZfilename_change_hookZset_filename_change_hookrr1color_breakpoint_text)r2argsr3r r r!r5s   zPyShellEditorWindow.__init__Cut<>rmenu_check_cutCopy<>rmenu_check_copyPaste <>rmenu_check_pasteNSet Breakpoint<>Clear Breakpoint<>TcCsD|jdkrdS|r(tj}tj|d}n ddd}|jjd|dS)z,Turn colorizing of breakpoint text on or offNbreak) foreground backgroundBREAK)r@r CurrentTheme GetHighlightr6Z tag_config)r2ZcolorthemeZcfgr r r!rAs  z)PyShellEditorWindow.color_breakpoint_textcCs|j}|jj}|jdd|d|dy|jj|Wn tk rX|jj|YnXy|jj j j }|j ||Wn YnXdS)NrTz%d.0r) r6r@rtag_addr4index ValueErrorappendr:pyshellinterpr r8)r2rr6rdebugr r r!set_breakpoints z"PyShellEditorWindow.set_breakpointcCs>|j}|jj}|s|jdStt|jd}|j|dS)Ninsert)r6r@rbellintfloatrYr_)r2eventr6rrr r r!r8sz'PyShellEditorWindow.set_breakpoint_herecCs|j}|jj}|s|jdStt|jd}y|jj|Wn YnX|j dddy|j j j j }|j||Wn YnXdS)Nr`rTzinsert linestartzinsert lineend +1char)r6r@rrarbrcrYr4remove tag_remover:r\r]r r9)r2rdr6rrr^r r r!r9s" z)PyShellEditorWindow.clear_breakpoint_herec Csd|jr`|j}|jj}|s$|jdSg|_|jddty|jjj j }|j |Wn YnXdS)NrTz1.0) r4r6r@rrarfZENDr:r\r]r clear_file_breaks)r2r6rr^r r r!rgs z%PyShellEditorWindow.clear_file_breakscCs|j}|jj}y$t|jd}|j}WdQRXWntk rJg}YnXynt|jdX}x$|D]}|j|dsb|j|qbW|j |j}|r|j|dt |dWdQRXWnVtk r}z8t |j ddsd|j _ tjd d t ||jd WYdd}~XnXdS) z#Save breakpoints when file is savedrNw= breakpoint_error_displayedFTz IDLE Errorz$Unable to update breakpoint list: %s)titlerr)r4r@ropenr? readlinesr startswithrupdate_breakpointsstrgetattrrootrl tkMessageBox showerrorr6)r2ZbreaksrfplinesZnew_filererrr r r!store_file_breakss.  (z%PyShellEditorWindow.store_file_breaksc Cs|jj|jdkrdS|jj}|dkr,dStjj|jrt|jd}|j }WdQRXxJ|D]B}|j |dr`t |t |dd}x|D]}|j |qWq`WdS)Nrhrjr)r6r,r@rr<r=isfiler?rnrorpevallenr_)r2rrwrxrZbreakpoint_linenumbersZbreakpoint_linenumberr r r!r1 s    z'PyShellEditorWindow.restore_file_breakscCs$|j}|jd}|j|}||_dS)z3Retrieves all the breakpoints in the current windowrTN)r6Z tag_rangesranges_to_linenumbersr4)r2r6rangesZlinenumber_listr r r!rqs  z&PyShellEditorWindow.update_breakpointscCsjg}x`tdt|dD]L}tt||j}tt||dj}x||kr`|j||d7}qDWqW|S)Nrr)ranger}rbrcstringr[)r2rrxrYrendr r r!r~"s  z)PyShellEditorWindow.ranges_to_linenumberscCs|jtj|dS)z7Extend base method - clear breaks when module is closedN)rgr_close)r2r r r!r3szPyShellEditorWindow._close)rCrDrE)rFrGrH)rIrJrK)NNN)rLrMN)rNrON)T)N)N)__name__ __module__ __qualname____doc__r5 rmenu_specsrAr_r8r9rgrzr1rqr~rr r r r!r0|s$  *r0c@s"eZdZdZeZdZdddZdS)PyShellFileListz8Extend base class: IDLE supports a shell and breakpointsNcCs8|jr|jjjnt||_|jr2|jjs2dS|jS)N)r\topwakeupPyShellbegin)r2rdr r r!r;Bs  zPyShellFileList.open_shell)N)rrrrr0rr\r;r r r r!r9src@s0eZdZdZddZddZddZdd Zd S) ModifiedColorDelegatorz8Extend base class: colorizer for the shell window itselfcCstj||jdS)N)r r5 LoadTagDefs)r2r r r!r5Ps zModifiedColorDelegator.__init__cCs*|jddd|jdddtj|dS)NZTODOz1.0iomarkZSYNC)rfrXr recolorize_main)r2r r r!rTsz&ModifiedColorDelegator.recolorize_maincCsJtj|tj}|jjdddtj|dtj|dtj|dddS)N)rSrRstdoutstderrconsole)stdinrrr)r rr rUtagdefsr,rV)r2rWr r r!rYs   z"ModifiedColorDelegator.LoadTagDefscCs"x|jD]}|j|ddqWdS)Nrr)rrf)r2tagr r r! removecolorscs z#ModifiedColorDelegator.removecolorsN)rrrrr5rrrr r r r!rMs  rc@s$eZdZdZdddZdddZdS) ModifiedUndoDelegatorz;Extend base class: forbid insert/delete before the I/O markNc CsLy"|jj|ddr |jjdSWntk r6YnXtj||||dS)NZ%dS)CModifiedInterpretercCsH||_tjdj}tj||dd|_d|_d|_t |_ |j j j |_dS)N__main__)localsF) tkconsolesysmodules__dict__rr5save_warnings_filters restartingsubprocess_arglistPORTportcompilecompilerflagsoriginal_compiler_flags)r2rrr r r!r5s zModifiedInterpreter.__init__NcCs&|jdkr|j|_tj|j|_dS)N)rbuild_subprocess_arglist subprocessPopen rpcsubproc)r2r r r!spawn_subprocesss  z$ModifiedInterpreter.spawn_subprocesscCs^ddtjD}tjdddddd}td kr8d |f}n d |f}tjg|d |t|jgS) NcSsg|] }d|qS)z-Wr ).0sr r r! sz@ModifiedInterpreter.build_subprocess_arglist..mainGeneralzdelete-exitfuncFbool)defaulttypezidlelib.pyshellz&__import__('idlelib.run').run.main(%r)z__import__('run').main(%r)z-c)r warnoptionsr GetOptionr executablerrr)r2riZ del_exitfZcommandr r r!rs    z,ModifiedInterpreter.build_subprocess_arglistc CsZt|jf}xLtdD]4}tj|yt||_PWqtk rFYqXqW|jdS|jj j d|_t dkr|jj j t jt jd|j|jj jdy|jjWnt jk r|jdSX|jjd|j|jjd|jj|jjd|jj|jjd|jj|jjd |jj|jjd t|jjd ||jd d |j|jS)Nrr rrrrr:r(r]T)with_cwd)HOSTrrtimeZsleeprrpccltrdisplay_port_binding_errorlistening_sockZ getsocknamerZ setsockoptsocketZ SOL_SOCKETZ SO_REUSEADDRrZ settimeoutaccepttimeoutdisplay_no_subprocess_errorregisterrrrrr:r( transfer_pathpoll_subprocess)r2Zaddrir r r!start_subprocesss>       z$ModifiedInterpreter.start_subprocessFrQcCsT|jr |jSd|_|j}|rYnXy|jjWntk rbYnX|jd|j_ d|_dS)NF) _afteridrr6Z after_cancelrrrrrr)r2r r r!kill_subprocesss z#ModifiedInterpreter.kill_subprocesscCsLy|jjWntk r"dSXy|jjWntk rFdSXdS)z"Make sure subprocess is terminatedN)rkillrwait)r2r r r!rsz(ModifiedInterpreter.terminate_subprocesscCs2|rdg}|jtjntj}|jd|fdS)NrQzRif 1: import sys as _sys _sys.path = %r del _sys )extendrr= runcommand)r2rr=r r r!r#s z!ModifiedInterpreter.transfer_pathcCs6|j}|dkrdSy|j|jdd}Wn2tttfk rX|jjrHdSd}|jYnX|r|jj d|_|\}}|jj }|dkr|dk rt t ||dnH|dkr|jj dr|jn*|dkrd}t ||tjdt |||dy|jjWntk rYnX|jjs2|jjj|jj|j|_dS) Ng?)rZOK)rZ EXCEPTIONz<>ERRORz/pyshell.ModifiedInterpreter: Subprocess ERROR: )rZ pollresponse active_seqrrKeyboardInterruptrclosingr resetoutputrprintreprgetvarremote_stack_viewerr __stderr__ endexecutingrr6after pollintervalrr)r2ZcltresponseZhowZwhatrerrmsgr r r!r2s@    z#ModifiedInterpreter.poll_subprocesscCs ||_dS)N)r )r2r r r r! setdebuggerZszModifiedInterpreter.setdebuggercCs|jS)N)r )r2r r r!r]szModifiedInterpreter.getdebuggercCs|jjjd|jdS)aInitiate the remote stack viewer from a separate thread. This method is called from the subprocess, and by returning from this method we allow the subprocess to unblock. After a bit the shell requests the subprocess to open the remote stack viewer which returns a static object looking at the last exception. It is queried through the RPC mechanism. i,N)rr6rr)r2r r r!open_remote_stack_viewer`s z,ModifiedInterpreter.open_remote_stack_viewerc Csddlm}|jjddd i}|dkr6|jjjdS|j|j|}ddlm }m }t |jj}t j }t j|dd}|||dd } | jjd d d || jd|} | jdS)Nr) debugobj_rrZ stackviewerr:)ScrolledCanvasTreeNodeZnormalrS)ZbgZhighlightthicknessrZboth)expandZfill)r:)idlelibrr remotequeuerrtraZStubObjectTreeItemZ idlelib.treerrZToplevelr rUrVframeZpackZcanvasr) r2rZoiditemrrrrWrSZscZnoder r r!rms   z'ModifiedInterpreter.remote_stack_viewerrcCs|j|}|j||dS)z1Like runsource() but assumes complete exec sourceN) stuffsourceexecfile)r2sourcerr r r! execsources zModifiedInterpreter.execsourcecCs|dkrFtj|.}|j}trd|j}|jd|_|jd}t|dd||ftj|<|S)z"Stuff source in the filename cachez rrkr)gidsplitr}r(r))r2r rrxr r r!r s    zModifiedInterpreter.stuffsourcecCs|jd|fdS)z>Prepend sys.path with file's directory if not already includeda(if 1: _filename = %r import sys as _sys from os.path import dirname as _dirname _dir = _dirname(_filename) if not _dir in _sys.path: _sys.path.insert(0, _dir) del _filename, _sys, _dirname, _dir N)r)r2rr r r!prepend_syspathsz#ModifiedInterpreter.prepend_syspathc Cs|j}|j}|jdddtj\}}}t|ddp:|p:d}t|ddpJd}t|d dpZd } | d krl|d7}|dkrd | d} nd |d| df} |j|| |j|jd ||j dS)zOverride Interactive Interpreter method: Use Colorizing Color the offending position instead of printing it and pointing at it with a caret. rz1.0rmsgrQzrroffsetrziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s N) rr6rfrexc_inforsZcolorize_syntax_errorrrr) r2rrr6rvaluetbr rr!posr r r!rs" z#ModifiedInterpreter.showsyntaxerrorcCs6|jj|jtj||jjdr2|jjdS)z1Extend base class method to reset output properlyz<>N)rrchecklinecacher showtracebackropen_stack_viewer)r2r r r!r's    z!ModifiedInterpreter.showtracebackcCsBtj}x6t|jD]&}|dd|dddkr||=qWdS)Nrz<>r')r(r)r*keys)r2cr.r r r!r&sz"ModifiedInterpreter.checklinecachecCs@|jjr|jdS|jr0|jjdd|fin t||jdS)z*Run the code without invoking the debuggerrrrr)rrdisplay_executing_dialogrrrr)r2rr r r!rs zModifiedInterpreter.runcommandcCst|jjr|jj|j|jdk r:|jtjdd<d|_|j}zyV|jj | rx|j dk rx|j j dd|fi|_ n |r|j ||jn t||jWntk r|jjstjddd|jjdr̂q|jnYnbtr td|jjd |j|jjn,|jjr0d |j_td |jjd n|jYnXWdtsny|jjWntk rlYnXXdS) zOverride base class methodNrrzExit?zDo you want to exit altogether?yes)rrz IDLE internal error in runcode())rFr)rrr]rr&rr$rr beginexecutingrZ asyncqueuerZrunrr SystemExitrruZaskyesnor6r'rrrrcanceledr)r2rr r r r!rsP         zModifiedInterpreter.runcodecCs|jjj|S)zOverride base class method)rrr)r2rr r r!r+szModifiedInterpreter.writecCstjdd|jjddS)NzPort Binding ErroraAIDLE can't bind to a TCP/IP port, which is necessary to communicate with its Python execution server. This might be because no networking is installed on this computer. Run IDLE with the -n command line switch to start without a subprocess and refer to Help/IDLE Help 'Running without a subprocess' for further details.)r)rurvrr6)r2r r r!r/sz.ModifiedInterpreter.display_port_binding_errorcCstjdd|jjddS)NzSubprocess Startup ErrorzIDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.)r)rurvrr6)r2r r r!r:sz/ModifiedInterpreter.display_no_subprocess_errorcCstjdd|jjddS)NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.)r)rurvrr6)r2r r r!r+Bsz,ModifiedInterpreter.display_executing_dialog)FrQ)F)N)N)&rrrr5rrrrrrrrrrrrrrr rrrrrr r rr rrr'r&rrrrrr+r r r r!rsF + - &    1 rcseZdZdedZeZeZdZd[d\d]d^d_gZ e j d`gZ ddl m Z daddZddZdZdZdZdZdZdZddZddZdbddZdd Zdcd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Z d/d0Z!d1d2Z"d3Z#d4d5Z$d6d7Z%d8d9Z&d:d;Z'dddd?Z)d@dAZ*dBdCZ+dDdEZ,dFdGZ-dedHdIZ.dfdJdKZ/dgdLdMZ0dNdOZ1dPdQZ2dRdSZ3ffdTdUZ4fdVdWZ5fdXdYZ6Z7S)hrzPython z Shellr_Fileedit_Editr^_Debugoptions_Optionswindow_Windowhelp_HelpSqueeze<>r)HistoryNc Cstr&|j}|dddkr&|jddt||_|dkrVt}t||jt|}t j ||ddd|_ d|_ t tdrtjnd|_|jjd d|_|j|_|j}|jd d |jd |j|jd|j|jd|j|jd|j|jd|j|jd|j|jd|jtr8|jd|j|jd|jtj |_!tj"|_#tj$|_%ddl&m'}t(|d|j)|_$t*|d|j)|_ t*|d|j)|_"t*|d|j)|_+ts|j t_ |j"t_"|j$t_$yddl,}|j-|_.Wntj/t_"YnX|j0|j|_1d|_2dS)NrrshellShe_llTps1z>>> rkrchar)wrapz<>z<>z<>z<>z<>z<>z<>z<>z<>)iomenurrrr2)r=r>r')3r menu_specsr`rr]Tkrwithdrawrrr5ZusetabsZ indentwidthhasattrrr@sys_ps1rZprompt_last_linepromptr6Z configurer7enter_callbacklinefeed_callbackcancel_callback eof_callbackr(toggle_debuggertoggle_jit_stack_viewerview_restart_mark restart_shellr save_stdoutr save_stderrr save_stdinrrCrencodingrrpydocZ plainpagerZpagerrr<historyr)r2r:Zmsrtr6rCrWr r r!r5ds`     zPyShell.__init__cCs tjddS)NT)Z shell_only)r Z GetExtensions)r2r r r!get_standard_extension_namessz$PyShell.get_standard_extension_namesFcCs|adS)N)r)r2streamr r r!set_warning_streamszPyShell.set_warning_streamcCstS)N)r)r2r r r!get_warning_streamszPyShell.get_warning_streamcCsH|jr$tjdd|jd|jdS|jj}|r<|jn|jdS)NzDon't debug nowz*You can only toggle the debugger when idle)rrP) rrurvr6set_debugger_indicatorr]rclose_debugger open_debugger)r2rddbr r r!rOs   zPyShell.toggle_debuggercCs|jj}|jd| dS)Nz<>)r]rZsetvar)r2r`r r r!r]s zPyShell.set_debugger_indicatorcCsdS)Nr )r2rdr r r!rPszPyShell.toggle_jit_stack_viewercCsh|jj}|r\|jjd|j|jjr8tj|jj|j|jj d|j |_ |j |j dS)Nz [DEBUG OFF] )r]rrrrr Zclose_remote_debuggerrrrrIrJrr])r2r`r r r!r^s   zPyShell.close_debuggercCsX|jjrtj|jj|}n tj|}|jj||jd|j|_ |j |j dS)Nz [DEBUG ON] ) r]rr Zstart_remote_debuggerr ZDebuggerrrrIrJrr])r2Zdbg_guir r r!r_s    zPyShell.open_debuggercCs|jd|_dS)zHelper for ModifiedInterpreterrN)rr)r2r r r!r-szPyShell.beginexecutingcCsd|_d|_|jdS)zHelper for ModifiedInterpreterrN)rr/r)r2r r r!rszPyShell.endexecutingcCsD|jr&tjddd|jd}|dkr&dS|jd|_d|_tj|S)zExtend EditorWindow.close()zKill?z7Your program is still running! Do you want to kill it?ok)rrFZcancelT) rruZ askokcancelr6rr/rrr)r2rr r r!rs z PyShell.closecCsV|jtr|jj|jt_|jt_|j t_ d|_d|_ d|j _ d|_tj|dS)zEExtend EditorWindow._close(), shut down debugger and execution serverN)r^rr]rrSrrrTrrUrrr:r\rXrr)r2r r r!rs zPyShell._closecCsdS)z8Override EditorWindow method: never remove the colorizerTr )r2rr r r!ispythonsource szPyShell.ispythonsourcecCs|jS)N) shell_title)r2r r r! short_title szPyShell.short_titlezHType "help", "copyright", "credits" or "license()" for more information.cCs|jjdd|jtr:d}|jj}|sF|jdSn d}tjt _|j d t j t j |j |f|jj|jd dl}d|_d S)Nrr`rQFz==== No Subprocess ==== z9WARNING: Running IDLE without a Subprocess is deprecated z;and will be removed in a later version. See Help/IDLE Help zfor details. zPython %s on %s %s %srTzR==== No Subprocess ==== WARNING: Running IDLE without a Subprocess is deprecated z==== No Subprocess ==== WARNING: Running IDLE without a Subprocess is deprecated and will be removed in a later version. See Help/IDLE Help z==== No Subprocess ==== WARNING: Running IDLE without a Subprocess is deprecated and will be removed in a later version. See Help/IDLE Help for details. )r6rrrr]rrr displayhookrrversionplatform COPYRIGHTZ focus_forcertkinterZ _default_root)r2ZnosubZclientrir r r!rs$  z PyShell.begincCs|js dSd|_|jjdS)NT)reading_stop_readline_flagrquit)r2r r r!r+szPyShell.stop_readlinec Cs|j}zd|_|jjWd||_X|jr4d|_dS|jjdd}t|dkrRd}|j|jrnd|_t snt |j r~d|_ d}|S)NrFrQrzend-1crrk) rjrmainlooprkr6getr}rr/rr endoffile)r2r-rr r r!readline1s( zPyShell.readlinecCsdS)NTr )r2r r r!isattyHszPyShell.isattyc Csy|jjdddrdSWn YnX|jp0|jsR|j|jjd|jdSd|_d|_ |jr|jj r|jj r|jj n |jj |jr|jjdS)Nz sel.firstz!=zsel.lastzKeyboardInterrupt rPrr)r6rrrjrr]rrror/rrrrrrl)r2rdr r r!rMKs&      zPyShell.cancel_callbackcCsh|jr|j rdS|jjdddo0|jjddds6dS|jsN|j|jnd|_d|_|jj dS)Nrz==r`zend-1crrrP) rrjr6rrrr/rorrl)r2rdr r r!rNas  zPyShell.eof_callbackcCs0|jr"|jjdd|jjdn |j|dS)Nr`rkrP)rjr6r`seenewline_and_indent_event)r2rdr r r!rLps  zPyShell.linefeed_callbackc Cs<|jr|j rdSy6|jjdd}|rF|jjdddrF|j||dSWn YnX|jjdddrX|jjd d}|r|jjdd|d r|j|jj|d |d |dS|jjd d}|r|jjd d |d r|j|jj|d |d |dS|jjdd}|r>|jj|d ddr>|j|jj|d d |n|j|jjdd |dS|jjdddrx|jjdd|jjdd}|r|j r|jj dd|jjdddr|j |dS|jjdd|jr|jj dd|jj dn |j ||jjd dd|jj|jr0|jjn|jdS)Nz sel.firstzsel.lastz<=rrPr`rziomark linestartrrrzinsert lineendz>=rzinsert linestartzend-1czend-1c linestartrk)rrjr6rnrrecallZ tag_prevrangeZ tag_nextrangerstriprrsr`rrrXZupdate_idletasksrrlrunit)r2rdselprevnextindicesrr r r!rKysX     zPyShell.enter_callbackc Cs<tjdd|}tjdd|}|jd}|jjz|jjddd|jjdd |jjd d}|jj d r|j ||jjd d}|jj d|d j t |d krtjd|d jd }tjd|jd }xJ|d dD]:}|j|r||t |d}|jj dd|jqWWd|jjd|jjXdS)Nz^\s*\nrQz\n\s*$rkrwz1.0rr`zend-1czinsert linestart:rrz ^([ \t]*))resubrr6Zundo_block_startrfrrnrstripendswithrsr`rur}searchgrouprprrZundo_block_stop)r2rrdrxprefixZorig_base_indentZnew_base_indentrr r r!rts*     zPyShell.recallcCs|jjdd}t|}x$|dkr:||ddkr:|d}qW|dkr\||ddkr\|d}x$|dkr||ddkr|d}q^W|d|}|jj|dS)Nrzend-1crrz rk)r6rnr}r]r)r2rrr r r!rvs   z PyShell.runitc CsX|jjr|jjSy tjWntjdd|jddSddlm }||j |j dS)NzNo stack tracez@There is no stack trace yet. (sys.last_traceback is not defined))rr) StackBrowser) r]rrrlast_tracebackrurvr6Zidlelib.stackviewerrrtr:)r2rdrr r r!r(s    zPyShell.open_stack_viewercCs|jjd|jjddS)Nrr)r6rr)r2rdr r r!rQs zPyShell.view_restart_markcCs|jjdddS)z&Callback for Run/Restart Shell Cntl-F6T)rN)r]r)r2rdr r r!rRszPyShell.restart_shellcCs:|j|jj|j|jjdd|j|jjdS)Nr`zend-1c) rrrrJr6rset_line_and_columnr@Z reset_undo)r2r r r!rs zPyShell.showpromptcCsP|jjj}t|ddd}dj|j|}|jds:|d7}|jjj d|ddS)Nr?T)rtabsizeZ expand_tabsrkziomark linestartr) r]rrr r>rBrZperZbottomr`)r2r rwrapperZ wrapped_msgr r r! show_warnings   zPyShell.show_warningcCsX|jjdd}|jr |jj||jjddkr>|jjdd|jjdd|jdS)Nrzend-1czend-2crk)r6rnrXZstorer`rr)r2r r r r!rs zPyShell.resetoutputc Cst|trRt|rRt|dkrRxt|D]\}}|dkr(Pq(Wtd|||ddy0|jjddtj |||d}|jjddWnYnX|j rd|_ t st |S) Nu￿zUCS-2rz%Non-BMP character not supported in Tkrrightrr) isinstancerrr}max enumerateUnicodeEncodeErrorr6rrrr/rr)r2rrrrAcountr r r!rs"z PyShell.writec s8y|jjdddrdSWntk r,dSXtjS)Nz sel.firstrrdisabled)r6rrsuperrE)r2) __class__r r!rE&s zPyShell.rmenu_check_cutcs|jjdddrdStjS)Nr`rrr)r6rrrK)r2)rr r!rK.szPyShell.rmenu_check_paste)rr0)r1r2)r^r3)r4r5)r6r7)r8r9)r:r;)N)N)N)N)N)N)N)8rrrrrcrr rrrErrZidlelib.historyr<r5rYrjrr/rorrkr[r\rOr]rPr^r_r-rrrrbrdrhrrrprqrMrNrLrKrtrvr(rQrRrrrrrErK __classcell__r r )rr!rJsj  <      ?     rcCs6|jdkr2x&dD]}|j|dd|j|dqWdS) z6Make paste replace selection on x11. See issue #5124.Zx11TextEntrySpinboxz <>z%catch {%W delete sel.first sel.last} N)rrr)Z_windowingsystemZ bind_class)rtclsr r r! fix_x11_paste4s  ra USAGE: idle [-deins] [-t title] [file]* idle [-dns] [-t title] (-c cmd | -r file) [arg]* idle [-dns] [-t title] - [arg]* -h print this help message and exit -n run IDLE without a subprocess (DEPRECATED, see Help/IDLE Help for details) The following options will override the IDLE 'settings' configuration: -e open an edit window -i open a shell window The following options imply -i and will open a shell: -c cmd run the command in a shell, or -r file run script from file -d enable the debugger -s run $IDLESTARTUP or $PYTHONSTARTUP before anything else -t title set title of shell window A default edit window will be bypassed when -c, -r, or - are used. [arg]* are passed to the command (-c) or script (-r) in sys.argv[1:]. Examples: idle Open an edit window or shell depending on IDLE's configuration. idle foo.py foobar.py Edit the files, also open a shell if configured to start with shell. idle -est "Baz" foo.py Run $IDLESTARTUP or $PYTHONSTARTUP, edit foo.py, and open a shell window with the title "Baz". idle -c "import sys; print(sys.argv)" "foo" Open a shell window and run the command, passing "-c" in sys.argv[0] and "foo" in sys.argv[1]. idle -d -s -r foo.py "Hello World" Open a shell window, run a startup script, enable the debugger, and run foo.py, passing "foo.py" in sys.argv[0] and "Hello World" in sys.argv[1]. echo "import sys; print(sys.argv)" | idle - "foobar" Open a shell window, run the script piped in, passing '' in sys.argv[0] and "foobar" in sys.argv[1]. cs\ddl}ddlm}ddlm}ddlm}tddad}d}d}d}d}d} y|jtj ddd\} } WnD|j k r} z&t d | t ftj d tjd WYdd} ~ XnXx| D]\} }| d kr|}d}| d krd}d}| dkrd}| dkr tjjt tj| dkrd}| dkr6t dtj d da| dkrj|}tjj|rTnt d|tjd}| dkr|d} d}| dkr|t_d}qW| r| ddkrtjj}d}x0tttjD]}tjjtj|tj|<qW| r| ddkrdg| ddt_ n|r$d g| t_ n|r8|g| t_ n| rd}g}x | D]}|jtjj|qLWxX|D],}tjj|}|tjkrntjjd|qnWn"tj}|tjkrtjjd|tj ddddd}|p|}|p| }tr| rt!t"dda#t#j$dd l%m&}|t#tjj'tjjt(d!|d"krbtjj'd#}t#j)|d$nBt*d%krpd&nd'fd(d)d1D}d-d)|D}t#j+d2|t,t#t-t#t.t#a/|j0t#t/|r|p|sx0| ddD] }t/j1|dkr| j2|qW| st/j3|rPt/j4}|s2dS|j5rVt/j6rV|j7j8nt/j9}|rd|j:| rtj;j||s|r|j=j?d0tj f|r|j=j@|n|r0|j=jA||j=j>|n8|r0|jBt#}|r|jC||jD}|r0|jC|xt/jErFt#jFq2Wt#jGtddS)3Nr)system)testing)macosxTFrz c:deihnr:st:z Error: %s %s)rrz-cz-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-t-rQrrzeditor-on-startupr)rZIdle)Z className)rZIconsZWindowszidle.ico)rg333333!@z.pngz.gifcs"g|]}tjjd|fqS)z idle_%d%s)r<r=r>)rsize)exticondirr r!rszmain.. 0cSsg|]}tt|dqS))Zmasterr)Z PhotoImagert)riconfiler r r!rsZ IDLESTARTUPZ PYTHONSTARTUPzbif 1: import sys as _sys _sys.argv = %r del _sys )rrr)T)Hgetoptrgrrrrr&rrargvrr usage_msgrexitrrr<r=r{rrcrrrr}rr[dirnamer`getcwdr rZ NoDefaultRootrFrtrG idlelib.runrr>__file__Z wm_iconbitmap TkVersionZ wm_iconphotorrrr:ZsetupApprnrenewr;ZisAquaTkdictrlowerr\r_environrnr]r rr rZtkVersionWarningrZpreferTabsPreferenceWarningZ inversedictrmZdestroy)rrrrZ enable_shellZ enable_editr^cmdZscriptZstartupZoptsrBr oarZpathxrdirZ edit_startrrZ iconfilesZiconsr=ZtkversionwarningZprefer_tabs_preference_warningr )rrr!rus                                   rrr\F)NN)Orri ImportErrorrrr.rgZctypesZPROCESS_SYSTEM_DPI_AWAREZOleDLLZSetProcessDpiAwarenessrrZtkinter.messageboxZ messageboxrurrFrtrGrrrvrrr(r<Zos.pathrr|rrtextwrapr rrrr$Zidlelib.colorizerr Zidlelib.configr rr r Zidlelib.editorrrZidlelib.filelistrZidlelib.outwinrrrrrZ idlelib.undorrrrr"r#r& checkcacher/r0rrrZ RPCClientrrrrrrrrr r r r!s                  >Hm?1