£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>
B
    YI~d              
   @   s  d dl Z edkr e jd e jd< yd dlT W n* ek
rV   ede jd edY nX e jdkry d dl	Z	dZ
e	d	e
 W n eeefk
r   Y nX d dlmZ ed
k re at  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/m0Z0m1Z1 d dl2m3Z3 d dl4m5Z5 d dl,m6Z6 d dlm7Z7m8Z8m9Z9 d dl:m;Z; dZ<d Z=e ja>d:ddZ?da@dd  ZAeAd! dejBfd"d#ZCeCe_BG d$d% d%e0ZDG d&d' d'e3ZEG d(d) d)e)ZFG d*d+ d+e;ZGG d,d- d-e6jHZId.d/ ZJG d0d1 d1eZKG d2d3 d3e5ZLd4d5 ZMd6ZNd7d8 ZOedkreO  eAd9 dS );    N__main__zidlelib.pyshell)*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StdInputFileStdOutputFile)UndoDelegatorz	127.0.0.1c          	   C   sP   |d krt }y&|t| ||||d |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"   4/opt/alt/python37/lib64/python3.7/idlelib/pyshell.pyidle_showwarningE   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_warningsX   s    r(   Tc             C   s\   t j}i }x:t|D ].}|d d |dd   dkr||||< qW ||  || d S )Nr   z<>)	linecachecachelistpopupdate)r    Zorig_checkcacher+   savekeyr"   r"   r#   extended_linecache_checkcacheg   s    r1   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d| j | jd| j | jd| jj t	j
tjd| _| jj| fdd}| j| | jjr|   |   d S )Nz<<set-breakpoint-here>>z<<clear-breakpoint-here>>z<<open-python-shell>>zbreakpoints.lstc             S   s   |   |   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    r3   color_breakpoint_text)r4   argsr5   r"   r"   r#   r7      s    zPyShellEditorWindow.__init__)ZCutz<<cut>>rmenu_check_cut)ZCopyz<<copy>>Zrmenu_check_copy)ZPastez	<<paste>>rmenu_check_paste)NNN)zSet Breakpointz<<set-breakpoint-here>>N)zClear Breakpointz<<clear-breakpoint-here>>NTc             C   sD   | j d krd S |r(t }t|d}n
ddd}| jd| d S )Nbreak )
foreground
backgroundBREAK)rB   r   CurrentThemeGetHighlightr8   Z
tag_config)r4   ZcolorthemeZcfgr"   r"   r#   rC      s    

z)PyShellEditorWindow.color_breakpoint_textc             C   s   | j }| jj}|dd| d|d   y| j| W n  tk
rX   | j| Y nX y| jj	j
j}||| W n   Y nX d S )NrK   z%d.0r   )r8   rB   r    tag_addr6   index
ValueErrorappendr<   pyshellinterpr   r:   )r4   r!   r8   r    debugr"   r"   r#   set_breakpoint   s    z"PyShellEditorWindow.set_breakpointNc             C   s>   | j }| jj}|s|  d S tt|d}| | d S )Ninsert)r8   rB   r    bellintfloatrP   rV   )r4   eventr8   r    r!   r"   r"   r#   r:      s    z'PyShellEditorWindow.set_breakpoint_herec             C   s   | j }| jj}|s|  d S tt|d}y| j| W n   Y nX |	ddd y| j
jjj}||| W n   Y nX d S )NrW   rK   zinsert linestartzinsert lineend +1char)r8   rB   r    rX   rY   rZ   rP   r6   remove
tag_remover<   rS   rT   r   r;   )r4   r[   r8   r    r!   rU   r"   r"   r#   r;      s"    z)PyShellEditorWindow.clear_breakpoint_herec             C   sd   | j r`| j}| jj}|s$|  d S g | _ |ddt y| jjj	j
}|| W n   Y nX d S )NrK   z1.0)r6   r8   rB   r    rX   r]   ZENDr<   rS   rT   r   clear_file_breaks)r4   r8   r    rU   r"   r"   r#   r^      s    z%PyShellEditorWindow.clear_file_breaksc          
   C   s  | j }| jj}y$t| jd}| }W d Q R X W n tk
rJ   g }Y nX ynt| jdX}x$|D ]}||d sb|| qbW | 	  | j }|r||d t
| d  W d Q R X W nT tk
r } z4t| jddsd| j_tjdd	t
| | jd
 W d d }~X Y nX d S )Nrw=
breakpoint_error_displayedFTz
IDLE Errorz$Unable to update breakpoint list:
%s)titler   r   )r6   rB   r    openrA   	readlinesr   
startswithr   update_breakpointsstrgetattrrootrc   tkMessageBox	showerrorr8   )r4   Zbreaksr    fplinesZnew_filer   errr"   r"   r#   store_file_breaks   s.    

(z%PyShellEditorWindow.store_file_breaksc          	   C   s   | j   | jd krd S | jj}|d kr,d S tj| jrt| jd}|	 }W d Q R X xJ|D ]B}|
|d r`t|t|d d  }x|D ]}| | qW q`W d S )Nr_   ra   r   )r8   r.   rB   r    r>   r?   isfilerA   re   rf   rg   evallenrV   )r4   r    rn   ro   r   Zbreakpoint_linenumbersZbreakpoint_linenumberr"   r"   r#   r3     s    



z'PyShellEditorWindow.restore_file_breaksc             C   s$   | j }|d}| |}|| _d S )NrK   )r8   Z
tag_rangesranges_to_linenumbersr6   )r4   r8   rangesZlinenumber_listr"   r"   r#   rh     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`|| |d7 }qDW qW |S )Nr      r   )rangert   rY   rZ   stringrR   )r4   rv   ro   rP   r!   endr"   r"   r#   ru   %  s    

z)PyShellEditorWindow.ranges_to_linenumbersc             C   s   |    t|  d S )N)r^   r   _close)r4   r"   r"   r#   r{   6  s    zPyShellEditorWindow._close)T)N)N)__name__
__module____qualname__r7   rmenu_specsrC   rV   r:   r;   r^   rq   r3   rh   ru   r{   r"   r"   r"   r#   r2   ~   s"   

	
*r2   c               @   s   e Zd ZeZdZdddZdS )PyShellFileListNc             C   s8   | j r| j j  nt| | _ | j r2| j  s2d S | j S )N)rS   topwakeupPyShellbegin)r4   r[   r"   r"   r#   r=   E  s    

zPyShellFileList.open_shell)N)r|   r}   r~   r2   r   rS   r=   r"   r"   r"   r#   r   <  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 |  |   d S )N)r   r7   LoadTagDefs)r4   r"   r"   r#   r7   S  s    
zModifiedColorDelegator.__init__c             C   s*   |  ddd | ddd t|  d S )NZTODOz1.0iomarkZSYNC)r]   rO   r   recolorize_main)r4   r"   r"   r#   r   W  s    z&ModifiedColorDelegator.recolorize_mainc          	   C   sJ   t |  t }| jd d dt|dt|dt|dd d S )N)rJ   rI   stdoutstderrconsole)stdinr   r   r   )r   r   r   rL   tagdefsr.   rM   )r4   rN   r"   r"   r#   r   \  s    


z"ModifiedColorDelegator.LoadTagDefsc             C   s"   x| j D ]}| |dd qW d S )Nr   rz   )r   r]   )r4   tagr"   r"   r#   removecolorsf  s    z#ModifiedColorDelegator.removecolorsN)r|   r}   r~   r7   r   r   r   r"   r"   r"   r#   r   P  s   
r   c               @   s    e Zd ZdddZdddZdS )ModifiedUndoDelegatorNc             C   sL   y"| j |ddr | j   d S W n tk
r6   Y nX t| ||| d S )N<r   )delegatecomparerX   TclErrorr   rW   )r4   rP   charstagsr"   r"   r#   rW   n  s    
zModifiedUndoDelegator.insertc             C   sJ   y"| j |ddr | j   d S W n tk
r6   Y nX t| || d S )Nr   r   )r   r   rX   r   r   delete)r4   Zindex1Zindex2r"   r"   r#   r   w  s    
zModifiedUndoDelegator.delete)N)N)r|   r}   r~   rW   r   r"   r"   r"   r#   r   k  s   
	r   c               @   s   e Zd Zdd ZdS )MyRPCClientc             C   s   t d S )N)EOFError)r4   r"   r"   r#   
handle_EOF  s    zMyRPCClient.handle_EOFN)r|   r}   r~   r   r"   r"   r"   r#   r     s   r   c             C   s^   d|pd d}| t |krNt| t | d\}}|| d  | |d  S |d d S d S )Nz= RESTART: ZShellz =rw   ra   )rt   divmod)widthr    r   Zdivmodr"   r"   r#   restart_line  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   sB   || _ tjd j}tj| |d d| _d | _t| _	| j
jj| _d S )Nr   )localsF)	tkconsolesysmodules__dict__r	   r7   
restartingsubprocess_arglistPORTportcompilecompilerflagsoriginal_compiler_flags)r4   r   r   r"   r"   r#   r7     s    zModifiedInterpreter.__init__Nc             C   s&   | j d kr|  | _ t| j | _d S )N)r   build_subprocess_arglist
subprocessPopen
rpcsubproc)r4   r"   r"   r#   spawn_subprocess  s    

z$ModifiedInterpreter.spawn_subprocessc             C   sJ   dd t jD }tjdddddd}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&__import__('idlelib.run').run.main(%r)z-c)r   warnoptionsr   	GetOption
executableri   r   )r4   r`   Z	del_exitfZcommandr"   r"   r#   r     s
    


z,ModifiedInterpreter.build_subprocess_arglistc          	   C   sZ  t | jf}xLtdD ]4}t| yt|| _P W q tk
rF   Y qX qW |   d S | jj	
 d | _tdkr| jj	tjtjd |   | jj	d y| j  W n tjk
r   |   d S X | jd| j | jd| jj | jd| jj | jd| jj | jd	| jj | jd
t | jd|  | jdd |   | jS )N   r   r   
   r   r   r   r   r<   r*   rT   T)with_cwd)HOSTr   rx   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)r4   Zaddrir"   r"   r#   start_subprocess  s>    




z$ModifiedInterpreter.start_subprocessFrH   c             C   s0  | j r| jS d| _ |  }|r<yt| j W n   Y nX | j  |   | j}|j}d|_| 	  y| j
  W n tjk
r   |   d S X | j|d |  |jdd |d |t|j| |jdd |jdd | s|  |rt| j |  | j| jj_d| _ | jS )	NTF)r   r   zend-1crb   restartleft)r   r   getdebuggerr   Zclose_subprocess_debuggercloseterminate_subprocessr   	executingr   r   r   r   r   r   stop_readliner8   r   r   r   r   mark_setmark_gravity
showpromptZrestart_subprocess_debuggerload_breakpointsr   r   r   r   )r4   r   r    rU   r   Zwas_executingr"   r"   r#   restart_subprocess  sF    

z&ModifiedInterpreter.restart_subprocessc             C   s   | j dddi  d S )NexecZinterrupt_the_serverr"   )r   Z
remotecall)r4   r"   r"   r#   Z__request_interrupt  s    z'ModifiedInterpreter.__request_interruptc             C   s   t j| jd  d S )N)target)	threadingZThread'_ModifiedInterpreter__request_interruptstart)r4   r"   r"   r#   interrupt_subprocess  s    z(ModifiedInterpreter.interrupt_subprocessc             C   s~   | j d k	r| jj| j  y| jj  W n tk
r>   Y nX y| j  W n tk
rb   Y nX |   d| j_	d | _d S )NF)
_afteridr   r8   Zafter_cancelr   r   r   r   r   r   )r4   r"   r"   r#   kill_subprocess  s    
z#ModifiedInterpreter.kill_subprocessc             C   sL   y| j   W n tk
r"   d S X y| j   W n tk
rF   d S X d S )N)r   killr   wait)r4   r"   r"   r#   r   !  s    z(ModifiedInterpreter.terminate_subprocessc             C   s2   |rdg}| tj ntj}| d|f  d S )NrH   zRif 1:
        import sys as _sys
        _sys.path = %r
        del _sys
        
)extendr   r?   
runcommand)r4   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 }|   Y nX |r| j	  d | _|\}}| jj
}|dkr|d k	rtt||d nH|dkr| jdr|   n*|dkrd}t||tjd t|||d y| j  W n tk
r   Y nX | jjs2| 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   r8   afterpollintervalr   r   )r4   ZcltresponseZhowZwhatr   errmsgr"   r"   r#   r   =  s@    


z#ModifiedInterpreter.poll_subprocessc             C   s
   || _ d S )N)r   )r4   r   r"   r"   r#   setdebuggere  s    zModifiedInterpreter.setdebuggerc             C   s   | j S )N)r   )r4   r"   r"   r#   r   h  s    zModifiedInterpreter.getdebuggerc             C   s   | j jd| j d S )Ni,  )r   r8   r   r   )r4   r"   r"   r#   open_remote_stack_viewerk  s    
z,ModifiedInterpreter.open_remote_stack_viewerc             C   s   ddl m} | jdddi }|d kr6| jj  d S || j|}ddlm	}m
} t| jj}t }t|dd }|||dd	}	|	jjd
dd ||	jd |}
|
  d S )Nr   )
debugobj_rr   Zstackviewer)r<   )ScrolledCanvasTreeNodeZnormalrJ   )bgZhighlightthicknessr   Zboth)expandfill)idlelibr   r   remotequeuer   rk   rX   ZStubObjectTreeItemZidlelib.treer   r   ZToplevelr   rL   rM   framepackZcanvasr   )r4   r   Zoiditemr   r   r   rN   rJ   ZscZnoder"   r"   r#   r   x  s    z'ModifiedInterpreter.remote_stack_viewerr   c             C   s   |  |}| || d S )N)stuffsourceexecfile)r4   sourcer    r"   r"   r#   
execsource  s    
zModifiedInterpreter.execsourcec          	   C   s   |d krFt |.}| }tr<dtj| d| d }W d Q R X yt||d}W nH tt	fk
r   | j
  td| j
jd t| | | j
  Y nX | | d S )Nz__file__ = r'''z'''
z
del __file__r   zB*** Error in script or command!
Traceback (most recent call last):)r   )tokenizere   readuse_subprocessr>   r?   abspathr   OverflowErrorSyntaxErrorr   r   r   r   r	   showsyntaxerrorr   runcode)r4   r    r  rn   coder"   r"   r#   r    s    &
zModifiedInterpreter.execfilec             C   s   |  |}t| ||S )N)r  r	   	runsource)r4   r  r    r"   r"   r#   r    s    
zModifiedInterpreter.runsourcec             C   s>   d| j  }| j d | _ |d}t|d d||ftj|< |S )Nz<pyshell#%d>r   rb   r   )gidsplitrt   r*   r+   )r4   r  r    ro   r"   r"   r#   r    s
    

zModifiedInterpreter.stuffsourcec             C   s   |  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   )r4   r    r"   r"   r#   prepend_syspath  s    z#ModifiedInterpreter.prepend_syspathc             C   s   | j }|j}|ddd t \}}}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 }
|||
 |  | d|  |	  d S )Nr   z1.0rz   msgrH   z<no detail available>r!   r   offsetr   ziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
)
r   r8   r]   r   exc_inforj   Zcolorize_syntax_errorr   r   r   )r4   r    r   r8   r   valuetbr  r!   r  posr"   r"   r#   r    s"    z#ModifiedInterpreter.showsyntaxerrorc             C   s6   | j   |   t|  | j dr2| j   d S )Nz<<toggle-jit-stack-viewer>>)r   r   checklinecacher	   showtracebackr   open_stack_viewer)r4   r"   r"   r#   r    s
    

z!ModifiedInterpreter.showtracebackc             C   sB   t j}x6t| D ]&}|d d |dd   dkr||= qW d S )Nr   r)   z<>)r*   r+   r,   keys)r4   cr0   r"   r"   r#   r    s    z"ModifiedInterpreter.checklinecachec             C   s@   | j jr|   dS | jr0| jdd|fi  nt|| j dS )Nr   r   r  r   )r   r   display_executing_dialogr   r   r   r   )r4   r  r"   r"   r#   r     s    zModifiedInterpreter.runcommandc             C   sN  | j jr| j  |   | j}zyT| j   |sT| jd k	rT| jdd|fi | _	n |rh|
|| j nt|| j W n tk
r   | j jstjddd| j jdr q|   n Y n`   trtd| j jd |   | j   n,| j jr
d	| j _td
| j jd n|   Y nX W d tsHy| j   W n tk
rF   Y nX X d S )Nr   r  zExit?zDo you want to exit altogether?Zyes)r   r   z IDLE internal error in runcode())r   Fr   )r   r   rT   r   r  r   beginexecutingr   Z
asyncqueuer   runr   r   
SystemExitr   rl   Zaskyesnor8   r  r	  r   r   r   canceledr   )r4   r  r   r"   r"   r#   r    sJ    




zModifiedInterpreter.runcodec             C   s   | j j|S )N)r   r   r   )r4   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   )rl   rm   r   r8   )r4   r"   r"   r#   r   '  s    z.ModifiedInterpreter.display_port_binding_errorc             C   s   t jdd| jjd d S )NzSubprocess Connection ErrorzIDLE's subprocess didn't make connection.
See the 'Startup failure' section of the IDLE doc, online at
https://docs.python.org/3/library/idle.html#startup-failure)r   )rl   rm   r   r8   )r4   r"   r"   r#   r   2  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   )rl   rm   r   r8   )r4   r"   r"   r#   r  :  s    z,ModifiedInterpreter.display_executing_dialog)FrH   )F)N)N)&r|   r}   r~   r7   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   	+
,
&
	
.r   c                   s  e Zd Zde  d ZeZeZddddddgZ	e
jd	g Zd
ZddlmZ dTddZdd Zd
Zd
Zd
Zd
Zd
Zd
Zdd Zdd ZdUddZdd ZdVddZdd Zdd Zd d! Zd"d# Zd$d% Z d&d' Z!d(d) Z"d*d+ Z#d,Z$d-d. Z%d/d0 Z&d1d2 Z'd3d4 Z(dWd5d6Z)d7d8 Z*d9d: Z+d;d< Z,d=d> Z-d?d@ Z.dXdAdBZ/dYdCdDZ0dZdEdFZ1dGdH Z2dIdJ Z3dKdL Z4d[dNdOZ5 fdPdQZ6 fdRdSZ7  Z8S )\r   zPython z Shell)r   Z_File)ZeditZ_Edit)rU   Z_Debug)optionsZ_Options)ZwindowZ_Window)helpZ_Help)ZSqueezez<<squeeze-current-text>>Fr   )HistoryNc             C   s$  t r&| j}|d d dkr&|dd t| | _|d krVt }t| |  t|}t	
| |d d  d| _d| _ttdrtjnd| _| jd	d
 | _| j| _| j}|jdd |d| j |d| j |d| j |d| j |d| j |d| j |d| j t r8|d| j |d| j |  | }|d|j! tj"| _#tj$| _%tj&| _'ddl(m)} t*| d|j+|j,| _&t-| d|j+|j,| _"t-| d|j+d| _$t-| d|j+|j,| _.t s| j"t_"| j$t_$| j&t_&ydd l/}|j0|_1W n   tj2t_$ Y nX | 3| j| _4d| _5d S )Nrw   r   shell)r'  ZShe_llT   ps1z>>> rb   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>>z<<squeeze-current-text>>)iomenur   r   r   backslashreplacer   2   )6r	  
menu_specsrW   r   rT   Tkr   withdrawr   r   r7   ZusetabsZindentwidthhasattrr   r)  sys_ps1r  Zprompt_last_linepromptr8   Z	configurer9   enter_callbacklinefeed_callbackcancel_callbackeof_callbackr  toggle_debuggertoggle_jit_stack_viewerview_restart_markrestart_shellZSqueezerZsqueeze_current_text_eventr   save_stdoutr   save_stderrr   
save_stdinr   r,  r   encodingerrorsr   r   pydocZ
plainpagerZpagerr   r&  historyr   )r4   r<   msrk   r8   Zsqueezerr,  rB  r"   r"   r#   r7   ^  sn    

zPyShell.__init__c             C   s   t jddS )NT)Z
shell_only)r   ZGetExtensions)r4   r"   r"   r#   get_standard_extension_names  s    z$PyShell.get_standard_extension_namesc             C   s   |a d S )N)r   )r4   streamr"   r"   r#   set_warning_stream  s    zPyShell.set_warning_streamc             C   s   t S )N)r   )r4   r"   r"   r#   get_warning_stream  s    zPyShell.get_warning_streamc             C   sH   | j r$tjdd| jd |   dS | j }|r<|   n|   d S )NzDon't debug nowz*You can only toggle the debugger when idle)r   rG   )	r   rl   rm   r8   set_debugger_indicatorrT   r   close_debuggeropen_debugger)r4   r[   dbr"   r"   r#   r9    s    


zPyShell.toggle_debuggerc             C   s   | j  }| d|   d S )Nz<<toggle-debugger>>)rT   r   Zsetvar)r4   rL  r"   r"   r#   rI    s    
zPyShell.set_debugger_indicatorc             C   s   d S )Nr"   )r4   r[   r"   r"   r#   r:    s    zPyShell.toggle_jit_stack_viewerc             C   sh   | j  }|r\| j d  |  | j jr8t| j j |   | j	d | j
| _|   |   d S )Nz[DEBUG OFF]
)rT   r   r   r   r   r   Zclose_remote_debuggerr   r   r   r3  r4  r   rI  )r4   rL  r"   r"   r#   rJ    s    
zPyShell.close_debuggerc             C   sX   | j jrt| j j| }n
t| }| j | |  d| j | _	| 
  |   d S )Nz[DEBUG ON]
)rT   r   r   Zstart_remote_debuggerr   ZDebuggerr   r   r3  r4  r   rI  )r4   Zdbg_guir"   r"   r#   rK    s    

zPyShell.open_debuggerc             C   s   |    d| _d S )NT)r   r   )r4   r"   r"   r#   r     s    zPyShell.beginexecutingc             C   s   d| _ d| _|   d S )NF)r   r#  r   )r4   r"   r"   r#   r     s    zPyShell.endexecutingc             C   sD   | j r&tjddd| jd}|dkr&dS |   d| _d| _t| S )NzKill?z7Your program is still running!
 Do you want to kill it?ok)r   r   FZcancelT)	r   rl   Zaskokcancelr8   r   r#  r   r   r   )r4   r   r"   r"   r#   r     s    
zPyShell.closec             C   sV   |    tr| j  | jt_| jt_| j	t_
d | _d | _d | j_d | _t|  d S )N)rJ  r	  rT   r   r=  r   r   r>  r   r?  r   r   r<   rS   rC  r   r{   )r4   r"   r"   r#   r{     s    
zPyShell._closec             C   s   dS )NTr"   )r4   r    r"   r"   r#   ispythonsource
  s    zPyShell.ispythonsourcec             C   s   | j S )N)shell_title)r4   r"   r"   r#   short_title  s    zPyShell.short_titlezHType "help", "copyright", "credits" or "license()" for more information.c             C   s   | j dd |   tr:d}| j }|sF|   dS nd}tjt	_| 
dt	jt	j| j|f  | j   |   dd l}d |_dS )	Nr   rW   rH   Fz==== No Subprocess ====

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

zPython %s on %s
%s
%sr   T)r8   r   r   r	  rT   r   r   r   displayhookr   r   versionplatform	COPYRIGHTZfocus_forcer   tkinterZ_default_root)r4   ZnosubZclientrU  r"   r"   r#   r     s"    

zPyShell.beginc             C   s   | j s
d S d| _| j  d S )NT)reading_stop_readline_flagr   quit)r4   r"   r"   r#   r   ,  s    zPyShell.stop_readlinec             C   s   | j }zd| _ | j  W d || _ X | jr4d| _dS | jdd}t|dkrRd}|   | jrnd| _t	snt
| jr~d| _d}|S )NTFrH   r   zend-1cr   rb   )rV  r   mainlooprW  r8   getrt   r   r#  r	  r   	endoffile)r4   r/   r   r"   r"   r#   readline2  s(    zPyShell.readlinec             C   s   dS )NTr"   )r4   r"   r"   r#   isattyI  s    zPyShell.isattyc             C   s   y| j dddrd S W n   Y nX | jsR| jsR|   | jd |   dS d| _d| _	| jr| jj
r| j r| j  n
| j  | jr| j  dS )Nz	sel.firstz!=zsel.lastzKeyboardInterrupt
rG   FT)r8   r   r   rV  r   rT   r   r   r[  r#  r   r   r   r   r   rX  )r4   r[   r"   r"   r#   r7  L  s&    


zPyShell.cancel_callbackc             C   sf   | j r| jsd S | jdddr0| jddds4d S | j sL|   |   nd| _d| _| j	  dS )Nr   z==rW   zend-1cFTrG   )
r   rV  r8   r   r   r   r#  r[  r   rX  )r4   r[   r"   r"   r#   r8  b  s    

zPyShell.eof_callbackc             C   s0   | j r"| jdd | jd n
| | dS )NrW   rb   rG   )rV  r8   rW   seenewline_and_indent_event)r4   r[   r"   r"   r#   r6  q  s
    
zPyShell.linefeed_callbackc             C   s8  | j r| jsd S y6| jdd}|rD| jdddrD| || dS W n   Y nX | jdddrV| jd	d}|r| jdd|d
 r| | j|d |d
 | dS | jd	d}|r| jdd|d r| | j|d |d
 | dS | jdd}|r<| j|d ddr<| | j|d
 d| n| | jdd| dS | jdddrv| jdd | jdd}|r|	 s| j
dd | jdddr| | dS | jdd | jr| jdd | jd n
| | | jd	dd | j  | jr,| j  n|   dS )Nz	sel.firstzsel.lastz<=r   rG   rW   r   ziomark linestartr   r   r   zinsert lineendz>=r   zinsert linestartzend-1czend-1c linestartrb   )r   rV  r8   rZ  r   recallZtag_prevrangeZtag_nextranger   stripr   r_  rW   r^  rO   Zupdate_idletasksr   rX  runit)r4   r[   selprevnextindicesr   r"   r"   r#   r5  z  sX    


zPyShell.enter_callbackc          	   C   s<  t dd|}t dd|}|d}| j  z| jddd | jdd	 | jd
d}| 	dr| 
| | jd
d}| jd|d   t|dkrt d|d d}t d|d}xJ|dd  D ]:}||r||t|d   }| jdd|   qW W d | jd | j  X d S )Nz^\s*\nrH   z\n\s*$rb   rc  z1.0rz   rW   zend-1czinsert linestart:r   r   z	^([ \t]*))resubr  r8   Zundo_block_startr]   r   rZ  rstripendswithr_  rW   ra  rt   searchgrouprg   r^  Zundo_block_stop)r4   r   r[   ro   prefixZorig_base_indentZnew_base_indentr   r"   r"   r#   r`    s*    


zPyShell.recallc             C   s   | 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| d S )Nr   zend-1cr   r   z 	rb   )r8   rZ  rt   rT   r  )r4   r   r   r"   r"   r#   rb    s    zPyShell.runitc             C   sX   | j jr| 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)rT   r   r   r   last_tracebackrl   rm   r8   Zidlelib.stackviewerro  rk   r<   )r4   r[   ro  r"   r"   r#   r    s    


zPyShell.open_stack_viewerc             C   s   | j d | j d d S )Nr   r   )r8   r^  )r4   r[   r"   r"   r#   r;    s    zPyShell.view_restart_markc             C   s   | j jdd d S )NT)r   )rT   r   )r4   r[   r"   r"   r#   r<    s    zPyShell.restart_shellc             C   s:   |    | j| j | jdd |   | j  d S )NrW   zend-1c)	r   r   r   r4  r8   r   set_line_and_columnrB   Z
reset_undo)r4   r"   r"   r#   r     s
    zPyShell.showpromptc             C   sP   | j jj}t|ddd}d||}|ds:|d7 }| jj	d|d d S )Nr(  T)r   tabsizeZexpand_tabsrb   ziomark linestartr   )
rT   r   r   r   r@   r+  rk  ZperZbottomrW   )r4   r  r   wrapperZwrapped_msgr"   r"   r#   show_warning  s    

zPyShell.show_warningc             C   sb   | j dd}| jr | j| | j ddkr>| j dd | j dd |   | j  d S )Nr   zend-1czend-2crb   )	r8   rZ  rC  storerW   r   rq  ZctipZremove_calltip_window)r4   r  r"   r"   r#   r     s    zPyShell.resetoutputr"   c             C   sX   y0| j dd t| ||d}| j dd W n    Y nX | jrTd| _tsTt|S )Nr   rightr   F)r8   r   r   r   r#  r	  r   )r4   r   r   countr"   r"   r#   r     s    zPyShell.writec                s8   y| j dddrdS W n tk
r,   dS X t  S )Nz	sel.firstr   r   disabled)r8   r   r   superrE   )r4   )	__class__r"   r#   rE     s    zPyShell.rmenu_check_cutc                s   | j dddrdS t  S )NrW   r   r   rx  )r8   r   ry  rF   )r4   )rz  r"   r#   rF   &  s    zPyShell.rmenu_check_paste)N)N)N)N)N)N)N)r"   )9r|   r}   r~   r
   rO  r   r   r   r   r/  r   r   Zallow_line_numbersZidlelib.historyr&  r7   rE  rV  r   r#  r[  r   rW  rG  rH  r9  rI  r:  rJ  rK  r   r   r   r{   rN  rP  rT  r   r   r\  r]  r7  r8  r6  r5  r`  rb  r  r;  r<  r   rt  r   r   rE   rF   __classcell__r"   r"   )rz  r#   r   B  sl   
C


	?




r   c          
   C   s6   | j dkr2x&dD ]}| |dd| |d  qW d S )NZx11)ZTextZEntryZSpinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
)Z_windowingsystemZ
bind_class)rk   clsr"   r"   r#   fix_x11_paste,  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           
      sn  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|  tj	dd  d\}
}W nD | j
k
r } z$td	|tf tjd
 td W d d }~X Y nX x|
D ]\}}|dkr|}d}|dkrd}d}|dkrd}|dkrtjt t  |dkrd}|dkr6tdtjd
 da|dkrj|}tj|rTntd| t  d}|dkr|d}	d}|dkr|t_d}qW |r|d dkrtj }d}x0tttjD ]}t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 ]}|tj| qLW xX|D ],}tj|}|tjkrntjd| qnW n"t }|tjkrtjd| tj ddddd}|p|}|p| }tr|st!  t"dda#t#$  dd l%m&} |t# tj'tjt(d!| d"kr`tj'd#}t#j)|d$ nV|* st+d%kr~d& d'}nd( d)} fd*d+|D }d,d+ |D }t#j,d0|  t-t# t.t# t/t#a0|1t#t0 |r,|s,|s,x0|d d  D ] }t02|d kr|3| qW |s,t04  |rbt05 }|sDd S |* rht0j6rh|j78  nt0j9}|rv|:  |	rtj;<d-ptj;<d.}|rtj|r|j=>| |s|r
|j=?d/tj	f  |r|j=@| n|rB|j=A| |j=>| n8|rB|Bt#}|r*|C| |D }|rB|C| xt0jErXt#F  qDW t#G  td d S )1Nr   )system)testing)macosxTFr   zc:deihnr:st:zError: %s
%s)r   rw   z-cz-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-t-rH   r   r   zeditor-on-startupr   )r   ZIdle)Z	className)r   ZIconsZWindowszidle.ico)r   g333333!@z.png)       0      z.gif)r  r  r  c                s"   g | ]}t jd | f qS )z	idle_%d%s)r>   r?   r@   )r   size)exticondirr"   r#   r     s   zmain.<locals>.<listcomp>c             S   s   g | ]}t t|d qS ))Zmasterr   )Z
PhotoImagerk   )r   iconfiler"   r"   r#   r     s   ZIDLESTARTUPZPYTHONSTARTUPzbif 1:
            import sys as _sys
            _sys.argv = %r
            del _sys
            
)T)HgetoptrS  r~  r   r  r  r(   r	  r   argverrorr   	usage_msgr   exitr   r   r>   r?   rr   r   rO  r   r  rx   rt   r
  rR   dirnamerW   getcwdr   r   ZNoDefaultRootr0  rk   r1  idlelib.runr   r@   __file__Zwm_iconbitmapZisAquaTk	TkVersionZwm_iconphotor   r}  r   r<   ZsetupAppre   r\   newr=   dictr   lowerrS   rK  environrZ  rT   r  r   r  r  ZtkVersionWarningrt  ZpreferTabsPreferenceWarningZinversedictrY  Zdestroy)r  r~  r  r  Zenable_shellZenable_editrU   cmdZscriptZstartupZoptsrD   r  oar   Zpathxr    dirZ
edit_startr   r  ZsizesZ	iconfilesZiconsr'  ZtkversionwarningZprefer_tabs_preference_warningr"   )r  r  r#   r   m  s   


















r   F)NN)Pr   r|   r   rU  ImportErrorr   r   r"  rS  ZctypesZPROCESS_SYSTEM_DPI_AWAREZOleDLLZSetProcessDpiAwarenessr   r   Ztkinter.messageboxZ
messageboxrl   r  r0  rk   r1  r  r   rm   r  r	   r*   r>   Zos.pathr
   rh  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(   
checkcacher1   r2   r   r   r   Z	RPCClientr   r   r   r   r}  r  r   r"   r"   r"   r#   <module>   s   


 ?   0   m? 6
