<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
2au                 @   s  d dl Z yd dlT W n* ek
r>   ede jd edY nX e jdkry d dlZdZej	dj
e W n eeefk
r   Y nX d dljZedk re atj  d d	lmZ et ejd
de td edd dlmZ d dlZd dlZd dlZd dlmZ d dlZd dlZd dlZd dl m!Z! d dl"Z"d dl#Z#d dl$Z$d dl%Z%d dl&m'Z' d dl(m)Z) d dl*m+Z+ d dl*m,Z, d dl-m.Z.m/Z/ d dl0m1Z1 d dl2m3Z3 d dl*m4Z4 d dlm5Z5m6Z6m7Z7 d dl8m9Z9 dZ:d Z;e ja<d8ddZ=da>dd Z?e?d dej@fd d!ZAeAe_@G d"d# d#e.ZBG d$d% d%e1ZCG d&d' d'e'ZDG d(d) d)e9ZEG d*d+ d+e4jFZGG d,d- d-eZHG d.d/ d/e3ZId0d1 ZJd2ZKd3d4 ZLeMd5kre jNd5 e jNd6< eL  e?d7 dS )9    N)*zJ** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **)file   win32Zshcoreg      !@)fix_scalingzIdle 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_formatwarningPseudoInputFilePseudoOutputFile)UndoDelegatorz	127.0.0.1c             C   sP   |d krt }y&|jt| ||||d |jd W n ttfk
rJ   Y nX d S )N)linez>>> )warning_streamwriter   AttributeErrorOSError)messagecategoryfilenamelinenor   r    r!   ,/opt/alt/python36/lib64/python3.6/pyshell.pyidle_showwarningC   s    r#   c             C   s0   | rt d kr,tja tt_nt d k	r,t t_d a d S )N)_warnings_showwarningwarningsshowwarningr#   )Zcapturer!   r!   r"   capture_warningsV   s    r'   Tc             C   s\   t j}i }x:t|D ].}|d d |dd   dkr|j|||< qW ||  |j| d S )Nr   z<>)	linecachecachelistpopupdate)r   Zorig_checkcacher*   savekeyr!   r!   r"   extended_linecache_checkcachee   s    r0   c               @   sz   e Zd Zdd Zd&d'd(d)d*d+gZd,ddZdd Zd-ddZd.ddZdd Z	dd Z
dd Zd d! Zd"d# Zd$d% ZdS )/PyShellEditorWindowc             G   s   g | _ tj| f|  | jjd| j | jjd| j | jjd| jj t	j
jtjd| _| jj| fdd}| jj| | jjr| j  | j  d S )Nz<<set-breakpoint-here>>z<<clear-breakpoint-here>>z<<open-python-shell>>zbreakpoints.lstc             S   s   |j   |   d S )N)restore_file_breaks)Zold_hookselfr!   r!   r"   filename_changed_hook   s    z;PyShellEditorWindow.__init__.<locals>.filename_changed_hook)breakpointsr   __init__textbindset_breakpoint_hereclear_breakpoint_hereflist
open_shellospathjoinr   ZuserdirbreakpointPathioZfilename_change_hookZset_filename_change_hookr   r2   color_breakpoint_text)r3   argsr4   r!   r!   r"   r6      s    zPyShellEditorWindow.__init__Cut<<cut>>rmenu_check_cutCopy<<copy>>rmenu_check_copyPaste	<<paste>>rmenu_check_pasteNSet Breakpoint<<set-breakpoint-here>>Clear Breakpoint<<clear-breakpoint-here>>Tc             C   sD   | j d krd S |r(tj }tj|d}n
ddd}| jjd| d S )Nbreak )
foreground
backgroundBREAK)rA   r   CurrentThemeGetHighlightr7   Z
tag_config)r3   ZcolorthemeZcfgr!   r!   r"   rB      s    

z)PyShellEditorWindow.color_breakpoint_textc             C   s   | j }| jj}|jdd| d|d   y| jj| W n  tk
rX   | jj| Y nX y| jj	j
j}|j|| W n   Y nX d S )NrU   z%d.0r   )r7   rA   r   tag_addr5   index
ValueErrorappendr;   pyshellinterpr   r9   )r3   r    r7   r   debugr!   r!   r"   set_breakpoint   s    z"PyShellEditorWindow.set_breakpointc             C   s>   | j }| jj}|s|j  d S tt|jd}| j| d S )Ninsert)r7   rA   r   bellintfloatrZ   r`   )r3   eventr7   r   r    r!   r!   r"   r9      s    z'PyShellEditorWindow.set_breakpoint_herec             C   s   | j }| jj}|s|j  d S tt|jd}y| jj| W n   Y nX |j	ddd y| j
jjj}|j|| W n   Y nX d S )Nra   rU   zinsert linestartzinsert lineend +1char)r7   rA   r   rb   rc   rd   rZ   r5   remove
tag_remover;   r]   r^   r   r:   )r3   re   r7   r   r    r_   r!   r!   r"   r:      s"    z)PyShellEditorWindow.clear_breakpoint_herec          	   C   sd   | j r`| j}| jj}|s$|j  d S g | _ |jddt y| jjj	j
}|j| W n   Y nX d S )NrU   z1.0)r5   r7   rA   r   rb   rg   ZENDr;   r]   r^   r   clear_file_breaks)r3   r7   r   r_   r!   r!   r"   rh      s    z%PyShellEditorWindow.clear_file_breaksc             C   s  | j }| jj}y$t| jd}|j }W d Q R X W n tk
rJ   g }Y nX ynt| jdX}x$|D ]}|j|d sb|j| qbW | j	  | j }|r|j|d t
| d  W d Q R X W nV tk
r } z8t| jdds d| j_tjdd	t
| | jd
 W Y d d }~X nX d S )Nrw=
breakpoint_error_displayedFTz
IDLE Errorz$Unable to update breakpoint list:
%s)titler   r   )r5   rA   r   openr@   	readlinesr   
startswithr   update_breakpointsstrgetattrrootrm   tkMessageBox	showerrorr7   )r3   Zbreaksr   fplinesZnew_filer   errr!   r!   r"   store_file_breaks   s.    

(z%PyShellEditorWindow.store_file_breaksc             C   s   | j j  | jd krd S | jj}|d kr,d S tjj| jrt| jd}|j	 }W d Q R X xJ|D ]B}|j
|d r`t|t|d d  }x|D ]}| j| qW q`W d S )Nri   rk   r   )r7   r-   rA   r   r=   r>   isfiler@   ro   rp   rq   evallenr`   )r3   r   rx   ry   r   Zbreakpoint_linenumbersZbreakpoint_linenumberr!   r!   r"   r2   
  s    



z'PyShellEditorWindow.restore_file_breaksc             C   s$   | j }|jd}| j|}|| _d S )NrU   )r7   Z
tag_rangesranges_to_linenumbersr5   )r3   r7   rangesZlinenumber_listr!   r!   r"   rr     s    

z&PyShellEditorWindow.update_breakpointsc             C   sj   g }x`t dt|dD ]L}tt|| j}tt||d  j}x||k r`|j| |d7 }qDW qW |S )Nr      r   )ranger~   rc   rd   stringr\   )r3   r   ry   rZ   r    endr!   r!   r"   r   "  s    

z)PyShellEditorWindow.ranges_to_linenumbersc             C   s   | j   tj|  d S )N)rh   r   _close)r3   r!   r!   r"   r   3  s    zPyShellEditorWindow._close)rD   rE   rF   )rG   rH   rI   )rJ   rK   rL   )NNN)rM   rN   N)rO   rP   N)T)N)N)__name__
__module____qualname__r6   rmenu_specsrB   r`   r9   r:   rh   r{   r2   rr   r   r   r!   r!   r!   r"   r1   |   s"   

	
*r1   c               @   s   e Zd ZeZdZdddZdS )PyShellFileListNc             C   s8   | j r| j jj  nt| | _ | j r2| j j s2d S | j S )N)r]   topwakeupPyShellbegin)r3   re   r!   r!   r"   r<   B  s    

zPyShellFileList.open_shell)N)r   r   r   r1   r   r]   r<   r!   r!   r!   r"   r   9  s   r   c               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
ModifiedColorDelegatorc             C   s   t j|  | j  d S )N)r   r6   LoadTagDefs)r3   r!   r!   r"   r6   P  s    
zModifiedColorDelegator.__init__c             C   s*   | j ddd | jddd tj|  d S )NZTODOz1.0iomarkZSYNC)rg   rY   r   recolorize_main)r3   r!   r!   r"   r   T  s    z&ModifiedColorDelegator.recolorize_mainc             C   sJ   t j|  tj }| jjd d dtj|dtj|dtj|dd d S )N)rT   rS   stdoutstderrconsole)stdinr   r   r   )r   r   r   rV   tagdefsr-   rW   )r3   rX   r!   r!   r"   r   Y  s    


z"ModifiedColorDelegator.LoadTagDefsc             C   s"   x| j D ]}| j|dd qW d S )Nr   r   )r   rg   )r3   tagr!   r!   r"   removecolorsc  s    z#ModifiedColorDelegator.removecolorsN)r   r   r   r6   r   r   r   r!   r!   r!   r"   r   M  s   
r   c               @   s    e Zd ZdddZdddZdS )ModifiedUndoDelegatorNc             C   sL   y"| j j|ddr | j j  d S W n tk
r6   Y nX tj| ||| d S )N<r   )delegatecomparerb   TclErrorr   ra   )r3   rZ   charstagsr!   r!   r"   ra   k  s    
zModifiedUndoDelegator.insertc             C   sJ   y"| j j|ddr | j j  d S W n tk
r6   Y nX tj| || d S )Nr   r   )r   r   rb   r   r   delete)r3   Zindex1Zindex2r!   r!   r"   r   t  s    
zModifiedUndoDelegator.delete)N)N)r   r   r   ra   r   r!   r!   r!   r"   r   h  s   
	r   c               @   s   e Zd Zdd ZdS )MyRPCClientc             C   s   t d S )N)EOFError)r3   r!   r!   r"   
handle_EOF  s    zMyRPCClient.handle_EOFN)r   r   r   r   r!   r!   r!   r"   r   ~  s   r   c               @   s  e Zd Zdd ZdZdZdZdd Zdd Zdd	 Z	d?ddZ
dd Zdd Zdd Zdd Zd@ddZdZdd ZdZdd Zdd Zdd Zd d! Zd"Zd#d$ ZdAd%d&Zd'd( Zd)d* Zd+d, ZdBd-d.Zd/d0 Zd1d2 Zd3d4 Z d5d6 Z!d7d8 Z"d9d: Z#d;d< Z$d=d> Z%dS )CModifiedInterpreterc             C   sH   || _ tjd j}tj| |d d | _d| _d | _t	| _
| jjj| _d S )N__main__)localsF)	tkconsolesysmodules__dict__r   r6   save_warnings_filters
restartingsubprocess_arglistPORTportcompilecompilerflagsoriginal_compiler_flags)r3   r   r   r!   r!   r"   r6     s    zModifiedInterpreter.__init__Nc             C   s&   | j d kr| j | _ tj| j | _d S )N)r   build_subprocess_arglist
subprocessPopen
rpcsubproc)r3   r!   r!   r"   spawn_subprocess  s    

z$ModifiedInterpreter.spawn_subprocessc             C   s^   dd t jD }tjdddddd}td	kr8d
|f }n
d|f }t jg| d|t| jg S )Nc             S   s   g | ]}d | qS )z-Wr!   ).0sr!   r!   r"   
<listcomp>  s    z@ModifiedInterpreter.build_subprocess_arglist.<locals>.<listcomp>mainGeneralzdelete-exitfuncFbool)defaulttypezidlelib.pyshellz&__import__('idlelib.run').run.main(%r)z__import__('run').main(%r)z-c)r   warnoptionsr   	GetOptionr   
executablers   r   )r3   rj   Z	del_exitfZcommandr!   r!   r"   r     s    


z,ModifiedInterpreter.build_subprocess_arglistc             C   sZ  t | jf}xLtdD ]4}tj| yt|| _P W q tk
rF   Y qX qW | j  d S | jj	j
 d | _tdkr| jj	jtjtjd | j  | jj	jd y| jj  W n tjk
r   | j  d S X | jjd| j | jjd| jj | jjd| jj | jjd| jj | jjd	| jj | jjd
t | jjd|  | jdd | j  | jS )N   r   r   
   r   r   r   r   r;   r)   r^   T)with_cwd)HOSTr   r   timeZsleepr   rpccltr   display_port_binding_errorlistening_sockZgetsocknamer   Z
setsockoptsocketZ
SOL_SOCKETZSO_REUSEADDRr   Z
settimeoutaccepttimeoutdisplay_no_subprocess_errorregisterr   r   r   r   r;   r)   transfer_pathpoll_subprocess)r3   Zaddrir!   r!   r"   start_subprocess  s>    




z$ModifiedInterpreter.start_subprocessFrR   c             C   sT  | j r| jS d| _ | j }|r<ytj| j W n   Y nX | jj  | j  | j}|j}d|_| j	  y| jj
  W n tjk
r   | j  d S X | j|d |j  |jjdd d|r|nd }t|jt| d d	 d
 }|jdj|| |jjdd |jjdd |s"|j  |r<tj| j |j  | j| jj_d| _ | jS )NTF)r   r   zend-1cz	RESTART: ZShell   r   rk   z
{0} {1} {0}restartleft) r   r   getdebuggerr   Zclose_subprocess_debuggercloseterminate_subprocessr   	executingr   r   r   r   r   r   stop_readliner7   r   rc   widthr~   r   formatmark_setmark_gravity
showpromptZrestart_subprocess_debuggerload_breakpointsr   r   r   r   )r3   r   r   r_   r   Zwas_executingr   Zhalfbarr!   r!   r"   restart_subprocess  sH    
z&ModifiedInterpreter.restart_subprocessc             C   s   | j jddf i  d S )NexecZinterrupt_the_server)r   Z
remotecall)r3   r!   r!   r"   Z__request_interrupt  s    z'ModifiedInterpreter.__request_interruptc             C   s   t j| jdj  d S )N)target)	threadingZThread'_ModifiedInterpreter__request_interruptstart)r3   r!   r!   r"   interrupt_subprocess  s    z(ModifiedInterpreter.interrupt_subprocessc             C   s~   | j d k	r| jjj| j  y| jjj  W n tk
r>   Y nX y| jj  W n tk
rb   Y nX | j  d| j_	d | _d S )NF)
_afteridr   r7   Zafter_cancelr   r   r   r   r   r   )r3   r!   r!   r"   kill_subprocess  s    
z#ModifiedInterpreter.kill_subprocessc             C   sL   y| j j  W n tk
r"   d S X y| j j  W n tk
rF   d S X d S )N)r   killr   wait)r3   r!   r!   r"   r     s    z(ModifiedInterpreter.terminate_subprocessc             C   s2   |rdg}|j tj ntj}| jd|f  d S )NrR   zRif 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
)extendr   r>   
runcommand)r3   r   r>   r!   r!   r"   r   #  s    z!ModifiedInterpreter.transfer_pathc             C   s6  | j }|d krd S y|j| jdd}W n2 tttfk
rX   | jjrHd S d }| j  Y nX |r| jj	  d | _|\}}| jj
}|dkr|d k	rtt||d nH|dkr| jjdr| j  n*|dkrd}t||tjd t|||d y| jj  W n tk
r   Y nX | jjs2| jjj| jj| j| _d S )	Ng?)r   ZOK)r   Z	EXCEPTIONz<<toggle-jit-stack-viewer>>ERRORz/pyshell.ModifiedInterpreter: Subprocess ERROR:
)r   Zpollresponse
active_seqr   r   KeyboardInterruptr   closingr   resetoutputr   printreprgetvarremote_stack_viewerr   
__stderr__endexecutingr   r7   afterpollintervalr   r   )r3   ZcltresponseZhowZwhatr   errmsgr!   r!   r"   r   2  s@    


z#ModifiedInterpreter.poll_subprocessc             C   s
   || _ d S )N)r   )r3   r   r!   r!   r"   setdebuggerZ  s    zModifiedInterpreter.setdebuggerc             C   s   | j S )N)r   )r3   r!   r!   r"   r   ]  s    zModifiedInterpreter.getdebuggerc             C   s   | j jjd| j d S )Ni,  )r   r7   r   r   )r3   r!   r!   r"   open_remote_stack_viewer`  s    
z,ModifiedInterpreter.open_remote_stack_viewerc             C   s   ddl m} | jjdddi }|d kr6| jjj  d S |j| j|}ddlm	}m
} t| jj}tj }tj|dd }|||dd	}	|	jjd
dd ||	jd |}
|
j  d S )Nr   )
debugobj_rr   Zstackviewerr;   )ScrolledCanvasTreeNodeZnormalrT   )bgZhighlightthicknessr   Zboth)expandfill)r;   )idlelibr  r   remotequeuer   ru   rb   ZStubObjectTreeItemZidlelib.treer  r  ZToplevelr   rV   rW   framepackZcanvasr  )r3   r  Zoiditemr  r  r   rX   rT   ZscZnoder!   r!   r"   r   m  s    z'ModifiedInterpreter.remote_stack_viewerr   c             C   s   | j |}| j|| d S )N)stuffsourceexecfile)r3   sourcer   r!   r!   r"   
execsource  s    
zModifiedInterpreter.execsourcec             C   s   |d krFt j|.}|j }tr<dtjj| d| d }W d Q R X yt||d}W nH tt	fk
r   | j
j  td| j
jd tj| | | j
j  Y nX | j| d S )Nz__file__ = r'''z'''
z
del __file__r   zB*** Error in script or command!
Traceback (most recent call last):)r   )tokenizero   readuse_subprocessr=   r>   abspathr   OverflowErrorSyntaxErrorr   r   r   r   r   showsyntaxerrorr   runcode)r3   r   r  rx   coder!   r!   r"   r    s    &
zModifiedInterpreter.execfilec             C   sd   | j |}d| _tjd d  | _tjdtd ztj| ||S | jd k	r^| jtjd d < d | _X d S )Nr   error)actionr   )	r  Zmorer%   filtersr   filterwarningsSyntaxWarningr   	runsource)r3   r  r   r!   r!   r"   r    s    

zModifiedInterpreter.runsourcec             C   s>   d| j  }| j d | _ |jd}t|d d||ftj|< |S )Nz<pyshell#%d>r   rl   r   )gidsplitr~   r)   r*   )r3   r  r   ry   r!   r!   r"   r    s
    

zModifiedInterpreter.stuffsourcec             C   s   | j d|f  d S )Na(  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
            
)r   )r3   r   r!   r!   r"   prepend_syspath  s    z#ModifiedInterpreter.prepend_syspathc             C   s   | j }|j}|jddd tj \}}}t|ddp:|p:d}t|ddpJd}t|d	dpZd
}	|	d
krl|d7 }|dkrd|	d  }
nd|d |	d f }
|j||
 |j  | jd|  |j	  d S )Nr   z1.0r   msgrR   z<no detail available>r    r   offsetr   ziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
)
r   r7   rg   r   exc_infort   Zcolorize_syntax_errorr   r   r   )r3   r   r   r7   r   valuetbr#  r    r$  posr!   r!   r"   r    s"    z#ModifiedInterpreter.showsyntaxerrorc             C   s6   | j j  | j  tj|  | j jdr2| j j  d S )Nz<<toggle-jit-stack-viewer>>)r   r   checklinecacher   showtracebackr   open_stack_viewer)r3   r!   r!   r"   r*    s
    

z!ModifiedInterpreter.showtracebackc             C   sB   t j}x6t|j D ]&}|d d |dd   dkr||= qW d S )Nr   z<>r(   )r)   r*   r+   keys)r3   cr/   r!   r!   r"   r)    s    z"ModifiedInterpreter.checklinecachec             C   s@   | j jr| j  dS | jr0| jjdd|fi  nt|| j dS )Nr   r   r  r   )r   r   display_executing_dialogr   r	  r   r   )r3   r  r!   r!   r"   r     s    zModifiedInterpreter.runcommandc             C   st  | j jr| jj  | j  | jd k	r:| jtjd d < d | _| j} zyV| j j	  | rx| j
d k	rx| j
jdd|fi | _n |r|j|| j nt|| j W n tk
r   | j jstjddd| j jdr̂ q| j  n Y nb   trtd| j jd | j  | j j  n,| j jr0d	| j _td
| j jd n| j  Y nX W d tsny| j j  W n tk
rl   Y nX X d S )Nr   r  zExit?zDo you want to exit altogether?yes)r   r   z IDLE internal error in runcode())r   Fr   )r   r   r^   r   r)  r   r%   r  r   beginexecutingr   Z
asyncqueuer   Zrunr   r   
SystemExitr   rv   Zaskyesnor7   r*  r  r   r   r   canceledr   )r3   r  r   r!   r!   r"   r    sP    





zModifiedInterpreter.runcodec             C   s   | j jj|S )N)r   r   r   )r3   r   r!   r!   r"   r   +  s    zModifiedInterpreter.writec             C   s   t jdd| jjd d S )NzPort Binding ErroraA  IDLE 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   )rv   rw   r   r7   )r3   r!   r!   r"   r   /  s    z.ModifiedInterpreter.display_port_binding_errorc             C   s   t jdd| jjd d S )NzSubprocess Startup ErrorzIDLE's subprocess didn't make connection.  Either IDLE can't start a subprocess or personal firewall software is blocking the connection.)r   )rv   rw   r   r7   )r3   r!   r!   r"   r   :  s    z/ModifiedInterpreter.display_no_subprocess_errorc             C   s   t jdd| jjd d S )NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.)r   )rv   rw   r   r7   )r3   r!   r!   r"   r.  B  s    z,ModifiedInterpreter.display_executing_dialog)FrR   )F)N)N)&r   r   r   r6   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r  r  r  r  r"  r  r*  r)  r   r  r   r   r   r.  r!   r!   r!   r"   r     sF   
+
-
&

1r   c                   s  e Zd Zde  d ZeZeZdZd[d\d]d^d_gZ	e
jd`g ZddlmZ daddZdd ZdZdZdZdZdZdZdd Zdd ZdbddZdd  Zdcd!d"Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Z d/d0 Z!d1d2 Z"d3Z#d4d5 Z$d6d7 Z%d8d9 Z&d:d; Z'ddd<d=Z(d>d? Z)d@dA Z*dBdC Z+dDdE Z,dFdG Z-dedHdIZ.dfdJdKZ/dgdLdMZ0dNdO Z1dPdQ Z2dRdS Z3f fdTdUZ4 fdVdWZ5 fdXdYZ6  Z7S )hr   zPython z Shellr   _Fileedit_Editr_   _Debugoptions_Optionswindow_Windowhelp_HelpSqueeze<<squeeze-current-text>>r   )HistoryNc          	   C   s  t r&| j}|d d dkr&|jdd t| | _|d krVt }t| |j  t|}t	j
| |d d  d| _d| _ttdrtjnd| _| jjd	d | _| j| _| j}|jdd |jd| j |jd| j |jd| j |jd| j |jd| j |jd| j |jd| j t r8|jd| j |jd| j tj | _!tj"| _#tj$| _%ddl&m'} t(| d|j)| _$t*| d|j)| _ t*| d|j)| _"t*| d|j)| _+t s| j t_ | j"t_"| j$t_$ydd l,}|j-|_.W n   tj/t_" Y nX | j0| j| _1d| _2d S )Nr   r   shellShe_llT   ps1z>>> rl   r   char)wrapz<<newline-and-indent>>z<<plain-newline-and-indent>>z<<interrupt-execution>>z<<end-of-file>>z<<open-stack-viewer>>z<<toggle-debugger>>z<<toggle-jit-stack-viewer>>z<<view-restart>>z<<restart-shell>>)iomenur   r   r   r   2   )r@  rA  r(   )3r  
menu_specsra   r   r^   Tkr   withdrawr   r   r6   ZusetabsZindentwidthhasattrr   rC  sys_ps1r!  Zprompt_last_linepromptr7   Z	configurer8   enter_callbacklinefeed_callbackcancel_callbackeof_callbackr+  toggle_debuggertoggle_jit_stack_viewerview_restart_markrestart_shellr   save_stdoutr   save_stderrr   
save_stdinr  rF  r   encodingr   r   pydocZ
plainpagerZpagerr   r?  historyr   )r3   r;   msru   r7   rF  rZ  r!   r!   r"   r6   d  s`    
zPyShell.__init__c             C   s   t jddS )NT)Z
shell_only)r   ZGetExtensions)r3   r!   r!   r"   get_standard_extension_names  s    z$PyShell.get_standard_extension_namesFc             C   s   |a d S )N)r   )r3   streamr!   r!   r"   set_warning_stream  s    zPyShell.set_warning_streamc             C   s   t S )N)r   )r3   r!   r!   r"   get_warning_stream  s    zPyShell.get_warning_streamc             C   sH   | j r$tjdd| jd | j  dS | jj }|r<| j  n| j  d S )NzDon't debug nowz*You can only toggle the debugger when idle)r   rQ   )	r   rv   rw   r7   set_debugger_indicatorr^   r   close_debuggeropen_debugger)r3   re   dbr!   r!   r"   rR    s    


zPyShell.toggle_debuggerc             C   s   | j j }| jd|   d S )Nz<<toggle-debugger>>)r^   r   Zsetvar)r3   rd  r!   r!   r"   ra    s    
zPyShell.set_debugger_indicatorc             C   s   d S )Nr!   )r3   re   r!   r!   r"   rS    s    zPyShell.toggle_jit_stack_viewerc             C   sh   | j j }|r\| j jd  |j  | j jr8tj| j j | j  | jj	d | j
| _| j  | j  d S )Nz[DEBUG OFF]
)r^   r   r   r   r   r   Zclose_remote_debuggerr   r   r   rL  rM  r   ra  )r3   rd  r!   r!   r"   rb    s    
zPyShell.close_debuggerc             C   sX   | j jrtj| j j| }n
tj| }| j j| |j  d| j | _	| j
  | j  d S )Nz[DEBUG ON]
)r^   r   r   Zstart_remote_debuggerr   ZDebuggerr   r   rL  rM  r   ra  )r3   Zdbg_guir!   r!   r"   rc    s    

zPyShell.open_debuggerc             C   s   | j   d| _d S )Nr   )r   r   )r3   r!   r!   r"   r0    s    zPyShell.beginexecutingc             C   s   d| _ d| _| j  d S )Nr   )r   r2  r   )r3   r!   r!   r"   r     s    zPyShell.endexecutingc             C   sD   | j r&tjddd| jd}|dkr&dS | j  d| _d| _tj| S )NzKill?z7Your program is still running!
 Do you want to kill it?ok)r   r   FZcancelT)	r   rv   Zaskokcancelr7   r   r2  r   r   r   )r3   r   r!   r!   r"   r     s    
zPyShell.closec             C   sV   | j   tr| jj  | jt_| jt_| j	t_
d | _d | _d | j_d | _tj|  d S )N)rb  r  r^   r   rV  r   r   rW  r   rX  r   r   r;   r]   r[  r   r   )r3   r!   r!   r"   r     s    
zPyShell._closec             C   s   dS )NTr!   )r3   r   r!   r!   r"   ispythonsource	  s    zPyShell.ispythonsourcec             C   s   | j S )N)shell_title)r3   r!   r!   r"   short_title  s    zPyShell.short_titlezHType "help", "copyright", "credits" or "license()" for more information.c             C   s   | j jdd | j  tr:d}| jj }|sF| j  dS nd}tjt	_| j
d	t	jt	j| j|f  | j j  | j  d
d l}d |_dS )Nr   ra   rR   Fz==== No Subprocess ====

z9WARNING: Running IDLE without a Subprocess is deprecated
z;and will be removed in a later version. See Help/IDLE Help
zfor details.

zPython %s on %s
%s
%sr   TzR==== 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.

)r7   r   r   r  r^   r   r   r   displayhookr   r   versionplatform	COPYRIGHTZfocus_forcer   tkinterZ_default_root)r3   ZnosubZclientrm  r!   r!   r"   r     s$    
 
zPyShell.beginc             C   s   | j s
d S d| _| jj  d S )NT)reading_stop_readline_flagr   quit)r3   r!   r!   r"   r   +  s    zPyShell.stop_readlinec             C   s   | j }zd| _ | jj  W d || _ X | jr4d| _dS | jjdd}t|dkrRd}| j  | jrnd| _t	snt
| jr~d| _d}|S )Nr   FrR   r   zend-1cr   rl   )rn  r   mainloopro  r7   getr~   r   r2  r  r   	endoffile)r3   r.   r   r!   r!   r"   readline1  s(    zPyShell.readlinec             C   s   dS )NTr!   )r3   r!   r!   r"   isattyH  s    zPyShell.isattyc          
   C   s   y| j jdddrd S W n   Y nX | jp0| jsR| j  | jjd | j  dS d| _d| _	| jr| jj
r| jj r| jj  n
| jj  | jr| jj  dS )Nz	sel.firstz!=zsel.lastzKeyboardInterrupt
rQ   r   r   )r7   r   r   rn  r   r^   r   r   rs  r2  r   r   r   r   r   rp  )r3   re   r!   r!   r"   rP  K  s&    


zPyShell.cancel_callbackc             C   sh   | j r| j rd S | jjdddo0| jjddds6d S | j sN| j  | j  nd| _d| _| jj	  dS )Nr   z==ra   zend-1cr   r   rQ   )
r   rn  r7   r   r   r   r2  rs  r   rp  )r3   re   r!   r!   r"   rQ  a  s    

zPyShell.eof_callbackc             C   s0   | j r"| jjdd | jjd n
| j| dS )Nra   rl   rQ   )rn  r7   ra   seenewline_and_indent_event)r3   re   r!   r!   r"   rO  p  s
    
zPyShell.linefeed_callbackc             C   s<  | j r| j rd S y6| jjdd}|rF| jjdddrF| j|| dS W n   Y nX | jjdddrX| jjd	d}|r| jjdd|d
 r| j| jj|d |d
 | dS | jjd	d}|r| jjdd|d r| j| jj|d |d
 | dS | jjdd}|r>| jj|d ddr>| j| jj|d
 d| n| j| jjdd| dS | jjdddrx| jjdd | jjdd}|r|j	  r| jj
dd | jjdddr| j| dS | jjdd | jr| jjdd | jjd n
| j| | jjd	dd | jj  | jr0| jj  n| j  dS )Nz	sel.firstzsel.lastz<=r   rQ   ra   r   ziomark linestartr   r   r   zinsert lineendz>=r   zinsert linestartzend-1czend-1c linestartrl   )r   rn  r7   rr  r   recallZtag_prevrangeZtag_nextranger   stripr   rw  ra   rv  rY   Zupdate_idletasksr   rp  runit)r3   re   selprevnextindicesr   r!   r!   r"   rN  y  sX    


zPyShell.enter_callbackc             C   s<  t jdd|}t jdd|}|jd}| jj  z| jjddd | jjdd	 | jjd
d}|j j	dr| j
| | jjd
d}| jjd|d j  t|dkrt jd|d jd}t jd|jd}xJ|dd  D ]:}|j|r||t|d   }| jjdd|j   qW W d | jjd | jj  X d S )Nz^\s*\nrR   z\n\s*$rl   r{  z1.0r   ra   zend-1czinsert linestart:r   r   z	^([ \t]*))resubr!  r7   Zundo_block_startrg   r   rr  rstripendswithrw  ra   ry  r~   searchgrouprq   rv  Zundo_block_stop)r3   r   re   ry   prefixZorig_base_indentZnew_base_indentr   r!   r!   r"   rx    s*    


zPyShell.recallc             C   s   | j jdd}t|}x$|dkr:||d  dkr:|d }qW |dkr\||d  dkr\|d }x$|dkr||d  dkr|d }q^W |d | }| jj| d S )Nr   zend-1cr   r   z 	rl   )r7   rr  r~   r^   r  )r3   r   r   r!   r!   r"   rz    s    zPyShell.runitc             C   sX   | j jr| j j S y
tj W n   tjdd| jd d S ddlm	} || j
| j d S )NzNo stack tracez@There is no stack trace yet.
(sys.last_traceback is not defined))r   r   )StackBrowser)r^   r   r   r   last_tracebackrv   rw   r7   Zidlelib.stackviewerr  ru   r;   )r3   re   r  r!   r!   r"   r+    s    


zPyShell.open_stack_viewerc             C   s   | j jd | j jd d S )Nr   r   )r7   rv  )r3   re   r!   r!   r"   rT    s    zPyShell.view_restart_markc             C   s   | j jdd d S )NT)r   )r^   r   )r3   re   r!   r!   r"   rU    s    zPyShell.restart_shellc             C   s:   | j   | jj| j | jjdd | j  | jj  d S )Nra   zend-1c)	r   r   r   rM  r7   r   set_line_and_columnrA   Z
reset_undo)r3   r!   r!   r"   r     s
    zPyShell.showpromptc             C   sP   | j jj}t|ddd}dj|j|}|jds:|d7 }| jjj	d|d d S )NrB  T)r   tabsizeexpand_tabsrl   ziomark linestartr   )
r^   r   r   r
   r?   rE  r  ZperZbottomra   )r3   r#  r   wrapperZwrapped_msgr!   r!   r"   show_warning  s    

zPyShell.show_warningc             C   sX   | j jdd}| jr | jj| | j jddkr>| j jdd | j jdd | j  d S )Nr   zend-1czend-2crl   )r7   rr  r[  storera   r   r  )r3   r  r!   r!   r"   r     s    zPyShell.resetoutputc             C   s   t |trRt|rRt|dkrRxt|D ]\}}|dkr(P q(W td|||d dy0| jjdd tj	| ||d}| jjdd W n    Y nX | j
rd| _
tst|S )	Nu   ￿zUCS-2r   z%Non-BMP character not supported in Tkr   rightr   r   )
isinstancers   r~   max	enumerateUnicodeEncodeErrorr7   r   r   r   r2  r  r   )r3   r   r   r   rD  countr!   r!   r"   r     s"    zPyShell.writec                s8   y| j jdddrdS W n tk
r,   dS X t j S )Nz	sel.firstr   r   disabled)r7   r   r   superrF   )r3   )	__class__r!   r"   rF   &  s    zPyShell.rmenu_check_cutc                s   | j jdddrdS t j S )Nra   r   r   r  )r7   r   r  rL   )r3   )r  r!   r"   rL   .  s    zPyShell.rmenu_check_paste)r   r3  )r4  r5  )r_   r6  )r7  r8  )r9  r:  )r;  r<  )r=  r>  )N)N)N)N)N)N)N)8r   r   r   r	   rg  r   r   r   r   rH  r   r   Zidlelib.historyr?  r6   r]  rn  r   r2  rs  r   ro  r_  r`  rR  ra  rS  rb  rc  r0  r   r   r   rf  rh  rl  r   r   rt  ru  rP  rQ  rO  rN  rx  rz  r+  rT  rU  r   r  r   r   rF   rL   __classcell__r!   r!   )r  r"   r   J  sj   
<


	?


	r   c             C   s6   | j dkr2x&dD ]}| j|dd| j|d  qW d S )NZx11TextEntrySpinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
)r  r  r  )Z_windowingsystemZ
bind_class)ru   clsr!   r!   r"   fix_x11_paste4  s    

r  a  
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].
c                 s\  dd l } ddlm} ddlm} ddlm} td dad}d}d}d }d }d}	y| j tj	dd  d\}
}W nD | j
k
r } z&td	|tf tjd
 tjd W Y d d }~X nX x|
D ]\}}|dkr|}d}|dkrd}d}|dkrd}|dkrtjjt tj  |dkrd}|dkr6tdtjd
 da|dkrj|}tjj|rTntd| tj  d}|dkr|d}	d}|dkr|t_d}qW |r|d dkrtjj }d}x0tttjD ]}tjjtj| tj|< qW |r|d dkrdg|dd   t_	n|r$dg| t_	n|r8|g| t_	n|rd}g }x |D ]}|jtjj| qLW xX|D ],}tjj|}|tjkrntjjd| qnW n"tj }|tjkrtjjd| tj ddddd}|p|}|p| }tr| rt!  t"dda#t#j$  dd l%m&} |t# tjj'tjjt(d!| d"krbtjj'd#}t#j)|d$ nBt*d%krpd&nd'  fd(d)d1D }d-d) |D }t#j+d2|  t,t# t-t# t.t#a/|j0t#t/ |r|p|sx0|d d  D ] }t/j1|d kr|j2| qW |st/j3  |rPt/j4 }|s2d S |j5 rVt/j6rV|j7j8  nt/j9}|rd|j:  |	rtj;j<d.ptj;j<d/}|rtjj|r|j=j>| |s|r|j=j?d0tj	f  |r|j=j@| n|r0|j=jA| |j=j>| n8|r0|jBt#}|r|jC| |jD }|r0|jC| xt/jErFt#jF  q2W t#jG  td d S )3Nr   )system)testing)macosxTFr   zc:deihnr:st:zError: %s
%s)r   r   z-cz-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-t-rR   r   r   zeditor-on-startupr   )r   ZIdle)Z	className)r   ZIconsZWindowszidle.ico)r   g333333!@z.pngz.gifc                s"   g | ]}t jjd | f qS )z	idle_%d%s)r=   r>   r?   )r   size)exticondirr!   r"   r     s   zmain.<locals>.<listcomp>       0   c             S   s   g | ]}t t|d qS ))Zmasterr   )Z
PhotoImageru   )r   iconfiler!   r!   r"   r     s   ZIDLESTARTUPZPYTHONSTARTUPzbif 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
)r  r  r  )T)Hgetoptrk  r  r  r  r  r'   r  r   argvr  r   	usage_msgr   exitr   r   r=   r>   r|   r   rg  r   r  r   r~   r  r\   dirnamera   getcwdr   r   ZNoDefaultRootrI  ru   rJ  idlelib.runr   r?   __file__Zwm_iconbitmap	TkVersionZwm_iconphotor   r  r   r;   ZsetupAppro   rf   newr<   ZisAquaTkdictr   lowerr]   rc  environrr  r^   r  r   r  r"  ZtkVersionWarningr  ZpreferTabsPreferenceWarningZinversedictrq  Zdestroy)r  r  r  r  Zenable_shellZenable_editr_   cmdZscriptZstartupZoptsrC   r#  oar   Zpathxr   dirZ
edit_startr   r  Z	iconfilesZiconsr@  ZtkversionwarningZprefer_tabs_preference_warningr!   )r  r  r"   r   u  s   
















r   r   r]   F)NN)Or   rm  ImportErrorr   r   r1  rk  ZctypesZPROCESS_SYSTEM_DPI_AWAREZOleDLLZSetProcessDpiAwarenessr   r   Ztkinter.messageboxZ
messageboxrv   r  rI  ru   rJ  r  r   rw   r  r   r)   r=   Zos.pathr	   r  r   r   textwrapr
   r   r   r  r%   Zidlelib.colorizerr   Zidlelib.configr   r  r   r   Zidlelib.editorr   r   Zidlelib.filelistr   Zidlelib.outwinr   r   r   r   r   Zidlelib.undor   r   r   r   r#   r$   r'   
checkcacher0   r1   r   r   r   Z	RPCClientr   r   r   r  r  r   r   r   r!   r!   r!   r"   <module>   s   



 >   H   m? 1
