
    d                         d dl Z edk    re j        d         e j        d<   	 d dlT n&# e$ r  ede j                    ed          w xY we j        dk    r9	 d dl	Z	dZ
 e	j        d	                              e
           n# eeef$ r Y nw xY wd d
lm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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( d dl)m*Z*m+Z+ d dl,m-Z- d dl.m/Z/ d dl&m0Z0 d dl&m1Z1 d dl2m3Z3m4Z4m5Z5 d dl6m7Z7 da8dZ9d Z:	 dZ;e;e<_;        e;e=_;        n# e>$ r Y nw xY we j        a?	 d5dZ@daAd ZB eBd           dejC        fd ZDeDe_C         G d! d"e*          ZE G d# d$e-          ZF G d% d&e!          ZG G d' d(e7          ZH G d) d*e%          ZI G d+ d,e1jJ                  ZKd- ZL G d. d/e          ZM G d0 d1e/          ZNd2 ZOd3ZPd4 ZQedk    r
 eQ              eBd           dS )6    N__main__zidlelib.pyshell)*zJ** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **file   win32shcore)
messagebox)InteractiveInterpreter)python_version)TextWrapper)ColorDelegator)idleConf)	Delegatordebugger)
debugger_r)EditorWindowfixwordbreaks)FileList)OutputWindow)replace)rpc)idle_formatwarningStdInputFileStdOutputFile)UndoDelegatorFz	127.0.0.1zCtrl-D (end-of-file)c           	          |t           }	 |                    t          | ||||                     |                    d           dS # t          t          f$ r Y dS w xY w)a   Show 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_streamwriter   AttributeErrorOSError)messagecategoryfilenamelinenor   r   s         !  /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/idlelib/pyshell.pyidle_showwarningr)   I   s     |

%8V$@ @ @ 	A 	A 	A

6G$   s   <A	 	AAc                     | r(t           t          j        a t          t          _        dS dS t           t           t          _        da dS dS )z>Replace warning.showwarning with idle_showwarning, or reverse.N)_warnings_showwarningwarningsshowwarningr)   )captures    r(   capture_warningsr/   \   sU      ) ($,$8!#3H    )( !,#8H $(!!! -,    Tc                     t           j        }i }t          |          D ]3}|dd         |dd         z   dk    r|                    |          ||<   4 ||            |                    |           dS )ao  Extend linecache.checkcache to preserve the <pyshell#...> entries

    Rather than repeating the linecache code, patch it to save the
    <pyshell#...> 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.
    Nr   <>)	linecachecachelistpopupdate)r&   orig_checkcacher5   savekeys        r(   extended_linecache_checkcacher<   k   s     OEDE{{ ' 'rr7SX%%		#DIOH	LLr0   c                   b    e Zd ZdZd Zg dZddZd ZddZdd	Z	d
 Z
d Zd Zd Zd Zd ZdS )PyShellEditorWindowz6Regular text edit window in IDLE, supports breakpointsc                    g | _         t          j        | g|R   | j                            d| j                   | j                            d| j                   | j                            d| j        j                   t          j
                            t          j        d          | _        | j        j        | fd}| j                            |           | j        j        r|                                  |                                  d S )N<<set-breakpoint-here>><<clear-breakpoint-here>>z<<open-python-shell>>zbreakpoints.lstc                 B    |                                   |              d S N)restore_file_breaks)old_hookselfs     r(   filename_changed_hookz;PyShellEditorWindow.__init__.<locals>.filename_changed_hook   s#    $$&&&HJJJJJr0   )breakpointsr   __init__textbindset_breakpoint_hereclear_breakpoint_hereflist
open_shellospathjoinr   userdirbreakpointPathiofilename_change_hookset_filename_change_hookr&   rD   color_breakpoint_text)rF   argsrG   s      r(   rI   zPyShellEditorWindow.__init__   s   d*T****	0$2JKKK	2D4NOOO	.
0EFFF !gll "35 5 ,07+G'+	 	 	 	 	(()>???7 	'$$&&&""$$$$$r0   ))Cutz<<cut>>rmenu_check_cut)Copyz<<copy>>rmenu_check_copy)Pastez	<<paste>>rmenu_check_paste)NNN)zSet Breakpointr@   N)zClear BreakpointrA   NTc                     | j         dS |r)t          j                    }t          j        |d          }nddd}| j                            d|           dS )z,Turn colorizing of breakpoint text on or offNbreak )
foreground
backgroundBREAK)rU   r   CurrentThemeGetHighlightrJ   
tag_config)rF   colorthemecfgs       r(   rX   z)PyShellEditorWindow.color_breakpoint_text   sc    7?F 	7)++E'w77CC!#266C	Wc*****r0   c                 b   | j         }| j        j        }|                    dd|z  d|dz   z             	 | j                            |           n*# t          $ r | j                            |           Y nw xY w	 | j        j	        j
        j        }|                    ||           d S #  Y d S xY w)Nre   z%d.0r   )rJ   rU   r&   tag_addrH   index
ValueErrorappendrN   pyshellinterpr   rL   )rF   r'   rJ   r&   debugs        r(   set_breakpointz"PyShellEditorWindow.set_breakpoint   s    y7#Wfvov/BCCC	,""6**** 	, 	, 	,##F+++++	,	J&-6E%%h77777	DDs   A $A76A7;,B) )B.Nc                     | j         }| j        j        }|s|                                 d S t	          t          |                    d                              }|                     |           d S )Ninsert)rJ   rU   r&   bellintfloatrn   rt   )rF   eventrJ   r&   r'   s        r(   rL   z'PyShellEditorWindow.set_breakpoint_here   sh    y7# 	IIKKKFU4::h//0011F#####r0   c                    | j         }| j        j        }|s|                                 d S t	          t          |                    d                              }	 | j                            |           n#  Y nxY w|	                    ddd           	 | j
        j        j        j        }|                    ||           d S #  Y d S xY w)Nrv   re   insert linestartzinsert lineend +1char)rJ   rU   r&   rw   rx   ry   rn   rH   remove
tag_removerN   rq   rr   r   rM   )rF   rz   rJ   r&   r'   rs   s         r(   rM   z)PyShellEditorWindow.clear_breakpoint_here   s    y7# 	IIKKKFU4::h//0011	##F++++	D!3/	1 	1 	1	J&-6E''&99999	DDs   A7 7A;,C C	c                    | j         r| j        }| j        j        }|s|                                 d S g | _         |                    ddt                     	 | j        j        j	        j
        }|                    |           d S #  Y d S xY wd S )Nre   1.0)rH   rJ   rU   r&   rw   r~   ENDrN   rq   rr   r   clear_file_breaks)rF   rJ   r&   rs   s       r(   r   z%PyShellEditorWindow.clear_file_breaks   s     	9Dw'H 		!DOOGUC000
*1:''11111	 	s   +B B	c                    | j         }| j        j        }	 t          | j                  5 }|                                }ddd           n# 1 swxY w Y   n# t          $ r g }Y nw xY w	 t          | j        d          5 }|D ]/}|                    |dz             s|                    |           0| 	                                 | j         }|r+|                    |dz   t          |          z   dz              ddd           dS # 1 swxY w Y   dS # t          $ r_}t          | j        dd          s>d| j        _        t          j        dd	t          |          z  | j        
           Y d}~dS Y d}~dS d}~ww xY w)z#Save breakpoints when file is savedNw=
breakpoint_error_displayedFTz
IDLE Errorz$Unable to update breakpoint list:
%s)titler$   parent)rH   rU   r&   openrT   	readlinesr#   
startswithr!   update_breakpointsstrgetattrrootr   r
   	showerrorrJ   )rF   breaksr&   fplinesnew_filer   errs           r(   store_file_breaksz%PyShellEditorWindow.store_file_breaks   so   $ !7#	d)** 'b' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 	 	 	EEE		&d)3// H8! - -D??8c>:: - t,,,'')))) HNN8c>CKK#?$#FGGGH H H H H H H H H H H H H H H H H H  	& 	& 	&49&BEJJ &7;	4$<Cc((#9& & & & & & & & & && & & & & &	&sq   A A
A 
AA AA A%$A%)D >A;D9D D

D D
D 
E<AE77E<c                    | j                                          | j        d S | j        j        }|d S t          j                            | j                  rt          | j                  5 }|	                                }d d d            n# 1 swxY w Y   |D ]]}|
                    |dz             rAt          |t          |          dz   d                    }|D ]}|                     |           \d S d S )Nr   r   )rJ   r8   rU   r&   rP   rQ   isfilerT   r   r   r   evallenrt   )rF   r&   r   r   r   breakpoint_linenumbersbreakpoint_linenumbers          r(   rD   z'PyShellEditorWindow.restore_file_breaks  sQ   	7?F7#F7>>$-.. 	Cd)** 'b' ' ' ' ' ' ' ' ' ' ' ' ' ' ' C C??8c>22 C-1$s8}}Q7G7G2H-I-I*1G C C-++,ABBBB	C 	CC Cs   +BBBc                 v    | j         }|                    d          }|                     |          }|| _        dS )z3Retrieves all the breakpoints in the current windowre   N)rJ   
tag_rangesranges_to_linenumbersrH   )rF   rJ   rangeslinenumber_lists       r(   r   z&PyShellEditorWindow.update_breakpoints"  s;    y))44V<<*r0   c                 :   g }t          dt          |          d          D ]y}t          t          ||         j                            }t          t          ||dz            j                            }||k     r |                    |           |dz  }||k      z|S )Nr      r   )ranger   rx   ry   stringrp   )rF   r   r   rn   r'   ends         r(   r   z)PyShellEditorWindow.ranges_to_linenumbers)  s    1c&kk1-- 	 	Eve}34455FeF57O23344C3,,V$$$! 3,, r0   c                 V    |                                   t          j        |            dS )z7Extend base method - clear breaks when module is closedN)r   r   _closerF   s    r(   r   zPyShellEditorWindow._close:  s+       D!!!!!r0   )TrC   )__name__
__module____qualname____doc__rI   rmenu_specsrX   rt   rL   rM   r   r   rD   r   r   r    r0   r(   r>   r>      s        <<% % %(  K
+ 
+ 
+ 
+  $ $ $ $   &  (& (& (&TC C C"+ + +  "" " " " "r0   r>   c                   "    e Zd ZdZeZdZddZdS )PyShellFileListz8Extend base class: IDLE supports a shell and breakpointsNc                     | j         r| j         j                                         n6t          |           | _         | j         r| j                                         sd S | j         S rC   )rq   topwakeupPyShellbeginrF   rz   s     r(   rO   zPyShellFileList.open_shellI  s`    < 	 L##%%%%"4==DL|  |))++  4|r0   rC   )r   r   r   r   r>   r   rq   rO   r   r0   r(   r   r   @  s:        >> 'LG     r0   r   c                       e Zd ZdZd Zd ZdS )ModifiedColorDelegatorz8Extend base class: colorizer for the shell window itselfc                     |                      ddd           |                     ddd           t          j        |            d S )NTODOr   iomarkSYNC)r~   rm   r   recolorize_mainr   s    r(   r   z&ModifiedColorDelegator.recolorize_mainV  sE    x000VUH---&t,,,,,r0   c                 H    | j         D ]}|                     |dd           d S )Nr   r   )tagdefsr~   )rF   tags     r(   removecolorsz#ModifiedColorDelegator.removecolors[  s6    < 	2 	2COOC51111	2 	2r0   N)r   r   r   r   r   r   r   r0   r(   r   r   T  s8        >>- - -
2 2 2 2 2r0   r   c                   2     e Zd ZdZddZddZ fdZ xZS )ModifiedUndoDelegatorz;Extend base class: forbid insert/delete before the I/O markNc                     	 | j                             |dd          r| j                                          d S n# t          $ r Y nw xY wt	          j        | |||           d S N<r   )delegatecomparerw   TclErrorr   rv   rF   rn   charstagss       r(   rv   zModifiedUndoDelegator.insertc  s    	}$$UC:: ""$$$  	 	 	D	T5%66666   5: 
AAc                     	 | j                             |dd          r| j                                          d S n# t          $ r Y nw xY wt	          j        | ||           d S r   )r   r   rw   r   r   delete)rF   index1index2s      r(   r   zModifiedUndoDelegator.deletel  s~    	}$$VS(;; ""$$$  	 	 	D	T6622222r   c                     | j         j        fd| j         _        	 t                                          |           | j         _        d S # | j         _        w xY w)Nc                      | |d          S Nstdinr   )rn   r   orig_inserts     r(   <lambda>z2ModifiedUndoDelegator.undo_event.<locals>.<lambda>|  s    UE7!C!C r0   )r   rv   super
undo_event)rF   rz   r   	__class__s     @r(   r   z ModifiedUndoDelegator.undo_eventu  si    
 m*CCCC 		/GGu%%%#.DM   ;DM ....s   !A ArC   )r   r   r   r   rv   r   r   __classcell__r   s   @r(   r   r   a  sf        AA7 7 7 73 3 3 3/ / / / / / / / /r0   r   c                       e Zd ZdZddZdS )UserInputTaggingDelegatorz.Delegator used to tag user input with "stdin".Nc                 F    |d}| j                             |||           d S r   )r   rv   r   s       r(   rv   z UserInputTaggingDelegator.insert  s,    <DUE400000r0   rC   )r   r   r   r   rv   r   r0   r(   r   r     s.        881 1 1 1 1 1r0   r   c                       e Zd Zd ZdS )MyRPCClientc                     t           )z0Override the base class - just re-raise EOFError)EOFErrorr   s    r(   
handle_EOFzMyRPCClient.handle_EOF  s    r0   N)r   r   r   r   r   r0   r(   r   r     s#            r0   r   c                     d|pd d}| t          |          k    r4t          | t          |          z
  d          \  }}||z   dz   | |dz   S |dd         S )zReturn width long restart line formatted with filename.

    Fill line with balanced '='s, with any extras and at least one at
    the beginning.  Do not end with a trailing space.
    z= RESTART: Shellz =r   r   N)r   divmod)widthr&   r   divmods        r(   restart_liner     sv     0+G
/
/
/CC5#c((?Q//Ss7C-//c#g///3B3xr0   c                       e Zd Zd ZdZdZdZd Zd Zd Z	d"dZ
d	 Zd
 Zd Zd Zd#dZdZd ZdZd Zd Zd Zd ZdZd Zd$dZd Zd Zd Zd$dZd Zd Zd Z d Z!d Z"d Z#d  Z$d! Z%dS )%ModifiedInterpreterc                     || _         t          j        d         j        }t	          j        | |           d| _        d | _        t          | _	        | j
        j        j        | _        d S )Nr   )localsF)	tkconsolesysmodules__dict__r   rI   
restartingsubprocess_arglistPORTportcompilecompilerflagsoriginal_compiler_flags)rF   r   r   s      r(   rI   zModifiedInterpreter.__init__  sZ    "Z(1'V<<<<"&	'+|'<'B$$$r0   Nc                     | j         |                                 | _         t          j        | j                   | _        d S rC   )r   build_subprocess_arglist
subprocessPopen
rpcsubprocr   s    r(   spawn_subprocessz$ModifiedInterpreter.spawn_subprocess  s8    "*&*&C&C&E&ED#$*4+BCCr0   c                     | j         dk    s
J d            d t          j        D             }t          j        ddddd	          }d
|d}t          j        g|z   d|t          | j                   gz   S )Nr   z/Socket should have been assigned a port number.c                     g | ]}d |z   S )z-Wr   ).0ss     r(   
<listcomp>z@ModifiedInterpreter.build_subprocess_arglist.<locals>.<listcomp>  s    ///!TAX///r0   mainGeneralzdelete-exitfuncFbool)defaulttypez#__import__('idlelib.run').run.main()-c)r   r   warnoptionsr   	GetOption
executabler   )rF   r   	del_exitfcommands       r(   r   z,ModifiedInterpreter.build_subprocess_arglist  s    	1= //s/// &vy:K/46C C C	F	FFF!#tWc$)nn&EEEr0   c                    t           | j        f}t          d          D ]<}t          j        |           	 t          |          | _         n&# t          $ r Y 9w xY w|                                  d S | j        j	        
                                d         | _        t          dk    r5| j        j	                            t          j        t          j        d           |                                  | j        j	                            d           	 | j                                         n%# t&          $ r |                                  Y d S w xY w| j                            d| j                   | j                            d| j        j                   | j                            d| j        j                   | j                            d| j        j                   | j                            d	| j        j                   | j                            d
t6                     | j                            d|            |                     d           |                                  | j        S )N   r   r   
   consoler   stdoutstderrrN   r4   rr   Twith_cwd)HOSTr   r   timesleepr   rpccltr#   display_port_binding_errorlistening_sockgetsocknamer   
setsockoptsocket
SOL_SOCKETSO_REUSEADDRr  
settimeoutacceptTimeoutErrordisplay_no_subprocess_errorregisterr   r   r  r  rN   r4   transfer_pathpoll_subprocess)rF   addris      r(   start_subprocessz$ModifiedInterpreter.start_subprocess  sE   di q 		 		AJqMMM)$//    ++---4K.::<<Q?	199
 K&11&2C+1+>C C C 	"--b111	K     	 	 	,,...44	 	Y777Wdn&:;;;Xt~'<===Xt~'<===Wdn&:;;;[)444Xt,,,D))){s#   A
AAD( (E
	E
Frb   c                 
   | j         r| j        S d| _         |                                 }|r"	 t          j        | j                   n#  Y nxY w| j                                         |                                  | j        }|j        }d|_        | 	                                 	 | j        
                                 n%# t          $ r |                                  Y d S w xY w|                     |           |                                 |j                            dd           |                    d           |                    t%          |j        |                     |j                            dd           |j                            dd           |s|                                 |r-t          j        | j                   |                                 | j        | j        j        _        d| _         | j        S )	NTFr  r   end-1cr   restartleft)r   r!  getdebuggerr   close_subprocess_debuggercloseterminate_subprocessr   	executingr  r*  r+  r,  r.  stop_readlinerJ   r   r!   r   r   mark_setmark_gravity
showpromptrestart_subprocess_debuggerload_breakpointsr   r   r   r   )rF   r  r&   rs   r  was_executings         r(   restart_subprocessz&ModifiedInterpreter.restart_subprocess  s   ? 	;  "" 	4T[AAAA!!###.)!	K     	 	 	,,...44	 	H---Hh///dl7=(;;<<<i222!!)V444 	!    	%24;???""$$$&*&B#{s   A A%B? ?C! C!c                 @    | j                             dddi            d S )Nexecinterrupt_the_serverr   )r!  
remotecallr   s    r(   __request_interruptz'ModifiedInterpreter.__request_interrupt  s%    v'=r2FFFFFr0   c                 ^    t          j        | j                                                   d S )N)target)	threadingThread'_ModifiedInterpreter__request_interruptstartr   s    r(   interrupt_subprocessz(ModifiedInterpreter.interrupt_subprocess  s+     8999??AAAAAr0   c                 `   | j         $| j        j                            | j                    	 | j        j                                         n# t          $ r Y nw xY w	 | j                                         n# t          $ r Y nw xY w|                                  d| j        _	        d | _        d S )NF)
_afteridr   rJ   after_cancelr!  r#  r9  r"   r:  r;  r   s    r(   kill_subprocessz#ModifiedInterpreter.kill_subprocess  s    =$N,,T];;;	K&,,.... 	 	 	D		K 	 	 	D	!!####( s#   A 
AAA7 7
BBc                     	 | j                                          	 | j                                          dS # t          $ r Y dS w xY w# t          $ r Y dS w xY w)z"Make sure subprocess is terminatedN)r  killwaitr#   r   s    r(   r:  z(ModifiedInterpreter.terminate_subprocess+  s    		O  """
$$&&&&&     	 	 	FF	s    A 7 
AA
AAc                     |r#dg}|                     t          j                   nt          j        }|                     d                    |                     d S )Nrb   zTif 1:
        import sys as _sys
        _sys.path = {!r}
        del _sys
        
)extendr   rQ   
runcommandformat)rF   r  rQ   s      r(   r.  z!ModifiedInterpreter.transfer_path8  sa     	4DKK!!!!8D  fTll		 	 	 	 	r0   c                 @   | j         }|d S 	 |                    | j        d          }nB# t          t          t
          f$ r( | j        j        rY d S d }|                                  Y nw xY w|r| j        	                                 d | _        |\  }}| j        j
        }|dk    r!|t          t          |          |           nk|dk    r/| j                            d          r|                                  n6|dk    r0d}t          ||t          j                   t          |||           	 | j                                         n# t$          $ r Y nw xY w| j        j        s6| j        j                            | j        j        | j                  | _        d S d S )	Ng?)rV  OKr   	EXCEPTION<<toggle-jit-stack-viewer>>ERRORz/pyshell.ModifiedInterpreter: Subprocess ERROR:
)r!  pollresponse
active_seqr   r#   KeyboardInterruptr   closingrC  resetoutputr  printreprgetvarremote_stack_viewerr   
__stderr__endexecutingr"   rJ   afterpollintervalr/  rQ  )rF   cltresponsehowwhatr  errmsgs          r(   r/  z#ModifiedInterpreter.poll_subprocessG  s   k;F	&''d'CCHH'#45 	& 	& 	& ~% H##%%%%%	&  	N&&((("DO ICn,Gd{{#$t**73333##>(()FGG /,,...Kfd8888fd1111++----!    ~% 	C N/55+T-AC CDMMM	C 	Cs'   * #A)A)(A)2E 
EEc                     || _         d S rC   r   )rF   r   s     r(   setdebuggerzModifiedInterpreter.setdebuggero  s     r0   c                     | j         S rC   r   r   s    r(   r7  zModifiedInterpreter.getdebuggerr  s
    }r0   c                 P    | j         j                            d| j                   dS )a  Initiate 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)r   rJ   rk  rh  r   s    r(   open_remote_stack_viewerz,ModifiedInterpreter.open_remote_stack_vieweru  s'     	!!#t'?@@@r0   c                    ddl m} | j                            dddi           }| | j        j                                         d S |                    | j        |          }ddlm	}m
} t          | j        j                  }t          j                    }t          j        |d          d         } |||d	          }	|	j                            d
d            ||	j        d |          }
|
                                 d S )Nr   )
debugobj_rrE  stackviewer)rN   )ScrolledCanvasTreeNodenormalrd   )bghighlightthicknessr   both)expandfill)idlelibrx  r!  remotequeuer   r   rw   StubObjectTreeItemidlelib.treerz  r{  Toplevelr   rf   rg   framepackcanvasr  )rF   rx  oiditemrz  r{  r   rj   rd   scnodes              r(   rh  z'ModifiedInterpreter.remote_stack_viewer  s
   &&&&&&k%%fmZLL;N$$&&&F,,T[#>>99999999t~*++%''*5(;;LI
^CJ1EEE
QV,,,x	4..r0   r   c                 \    |                      |          }|                     ||           dS )z1Like runsource() but assumes complete exec sourceN)stuffsourceexecfilerF   sourcer&   s      r(   
execsourcezModifiedInterpreter.execsource  s/    ##F++h'''''r0   c                 ,   |pt          j        |          5 }|                                }t          r)dt          j                            |           d|z   dz   }ddd           n# 1 swxY w Y   	 t          ||d          }|                     |           dS # t          t          f$ rf | j                                         t          d| j        j                   t          j        | |           | j                                         Y dS w xY w)zExecute an existing fileNz__file__ = r'''z'''
z
del __file__rE  zB*** Error in script or command!
Traceback (most recent call last):r   )tokenizer   readuse_subprocessrP   rQ   abspathr   runcodeOverflowErrorSyntaxErrorr   rd  re  r  r   showsyntaxerrorr?  )rF   r&   r  r   codes        r(   r  zModifiedInterpreter.execfile  sh   >x(( ;B! ;P0I0IPPP &')9:F; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

	68V44D LL {+ 	( 	( 	(N&&((( 6~,. . . . #24BBBN%%''''''	(s%   AA((A,/A,4B A3DDc                     |                      |          }t          |t                    sJ t          j        | ||          S )zBExtend base class method: Stuff the source in the line cache first)r  
isinstancer   r   	runsourcer  s      r(   r  zModifiedInterpreter.runsource  sB    ##F++&#&&&&& &/fhGGGr0   c                     d| j         z  }| j         dz   | _         |                    d          }t          |          dz   d||ft          j        |<   |S )z"Stuff source in the filename cachez<pyshell#%d>r   r   r   )gidsplitr   r4   r5   )rF   r  r&   r   s       r(   r  zModifiedInterpreter.stuffsource  sP    !DH,8a<T""$'KKM1eX$E	!r0   c                 V    |                      d                    |                     dS )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)rY  rZ  rF   r&   s     r(   prepend_syspathz#ModifiedInterpreter.prepend_syspath  s6      &""	$ 	$ 	$ 	$ 	$r0   c                    | j         }|j        }|                    ddd           t          j                    \  }}}t          |dd          p|pd}t          |dd          pd}t          |d	d          pd
}	|	d
k    r|dz  }|dk    r	d|	dz
  z  }
nd|dz
  |	dz
  fz  }
|                    ||
           |                                 |                     d|z             |	                                 dS )zOverride Interactive Interpreter method: Use Colorizing

        Color the offending position instead of printing it and pointing at it
        with a caret.

        r_  r   r   msgrb   z<no detail available>r'   r   offsetr   ziomark + %d charsz&iomark linestart + %d lines + %d charszSyntaxError: %s
N)
r   rJ   r~   r   exc_infor   colorize_syntax_errorrd  r!   r?  )rF   r&   r   rJ   r  valuetbr  r'   r  poss              r(   r  z#ModifiedInterpreter.showsyntaxerror  s    N	~...,..eReUB''K5K4K"--2"--2Q;;aKFQ;;%2CC:!8VAX&'C''c222

&,---r0   c                     | j                                          |                                  t          j        |            | j                             d          r| j                                          dS dS )z1Extend base class method to reset output properlyr^  N)r   rd  checklinecacher   showtracebackrg  open_stack_viewerr   s    r(   r  z!ModifiedInterpreter.showtraceback  sv    ""$$$,T222>  !>?? 	/N,,.....	/ 	/r0   c                     t           j        }t          |                                          D ]}|d d         |dd          z   dk    r||= d S )Nr   r2   r3   )r4   r5   r6   keys)rF   cr;   s      r(   r  z"ModifiedInterpreter.checklinecache  sX    O>> 	 	C2A2wRSS!T))cF	 	r0   c                     | j         j        r|                                  dS | j        r| j                            dd|fi            nt          || j                   dS )z*Run the code without invoking the debuggerr   rE  r  r   )r   r;  display_executing_dialogr!  r  rE  r   )rF   r  s     r(   rY  zModifiedInterpreter.runcommand  sj     ># 	))+++1; 	$K##FIwCCCCt{###qr0   c                    | j         j        r|                                  |                                  | j        }	 | j                                          |s+| j        $| j                            dd|fi           | _        n.|r |j	        || j
                   nt          || j
                   n# t          $ rH | j         j        s8t          j        ddd| j         j                  r |                                  n Y n t$          rIt'          d| j         j        	           |                                  | j                                          nH| j         j        r(d
| j         _        t'          d| j         j        	           n|                                  Y nxY wt$          s-	 | j                                          dS # t.          $ r Y dS w xY wdS # t$          s+	 | j                                          w # t.          $ r Y w w xY ww xY w)Override base class methodNrE  r  zExit?zDo you want to exit altogether?yesr  r   z IDLE internal error in runcode()r   Frb  )r   r;  rC  r  r   beginexecutingr!  
asyncqueuera  runr   rE  
SystemExitrc  r
   askyesnorJ   r  r  re  r  rj  canceledr"   )rF   r  r   s      r(   r  zModifiedInterpreter.runcode  so   ># 	&##%%%=&	N))+++ ( 7"&+"8"89=#E #E (T4;////T4;''' 	 	 	>) 
&5!>.	0 0 0 )
 &&(((( )(	) 
)8>02 2 2 2""$$$++---->* ).3DN+-DN4IJJJJJ&&(((! N//11111%   DD > N//1111%   Dsb   A4B2 1G 2AFG BFG )G 
GGH G:9H:
HHHHc                 @    | j         j                            |          S )r  )r   r  r!   )rF   r  s     r(   r!   zModifiedInterpreter.write-  s    ~$**1---r0   c                 H    t          j        dd| j        j                   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   r
   r   r   rJ   r   s    r(   r"  z.ModifiedInterpreter.display_port_binding_error1  s8     / >&	( 	( 	( 	( 	( 	(r0   c                 H    t          j        dd| j        j                   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-failurer  r  r   s    r(   r,  z/ModifiedInterpreter.display_no_subprocess_error<  s9    )J >&	( 	( 	( 	( 	( 	(r0   c                 H    t          j        dd| j        j                   d S )NzAlready executingzYThe Python Shell window is already executing a command; please wait until it is finished.r  r  r   s    r(   r  z,ModifiedInterpreter.display_executing_dialogD  s6    0>&		( 	( 	( 	( 	( 	(r0   )Frb   )FrC   )&r   r   r   rI   rQ  r!  r  r  r   r2  rC  rM  rO  rS  r:  r.  ra  r/  r   rs  r7  rv  rh  r  r  r  r  r  r  r  r  r  rY  r  r!   r"  r,  r  r   r0   r(   r   r     s       C C C HFJD D D

F 
F 
F) ) )V* * * *XG G GB B B        J$C $C $CL H! ! !      " C( ( (
   (H H H  
$ 
$ 
$   4/ / /  
 
 
, , ,\. . .	( 	( 	(( ( (( ( ( ( (r0   r   c            	       X    e Zd ZddlmZ d e            z   ZeZe	Z
g dZej        dgz   Zd e e ej        d e                              z   Ze                    ed           [d	Zd
ZddlmZ ddlmZ d;dZ fdZ fdZd Zd Zd Zd;dZ d	Z!d	Z"d	Z#d	Z$d	Z%d	Z&d Z'd Z(d;dZ)d Z*d;dZ+d Z,d Z-d Z.d Z/d Z0d Z1d  Z2d! Z3d" Z4d#Z5d$ Z6d% Z7d& Z8d' Z9d;d(Z:d) Z;d* Z<d+ Z=d, Z> e?j@        d-          ZAd. ZBd;d/ZCd;d0ZDd;d1ZEd2 ZFd3 ZGd4 ZHd<d6ZI fd7ZJ fd8ZKd;d9ZLd: ZM xZNS )=r   r   )SqueezerzIDLE Shell ))r   _File)edit_Edit)rs   _Debug)options_Options)window_Window)help_Help)Squeeze<<squeeze-current-text>>r   c                     | d         dk    S )Nr   r\   r   )
rmenu_items    r(   r   zPyShell.<lambda>d  s    :a=F2 r0   )zCopy with prompts<<copy-with-prompts>>r]   Fr   )History)ShellSidebarNc                 8   t           r/| j        }|d         d         dk    r|                    dd           t          |           | _        |@t                      }t          |           |                                 t          |          }d | _	        t          j        | |d d            d| _        d| _        t          t          d          rt          j        nd| _        | j                            d	          d
         | _        | j        | _        | j        }|                    d           |                    d| j                   |                    d| j                   |                    d| j                   |                    d| j                   |                    d| j                   |                    d| j                   |                    d| j                   |                    d| j                   t           r6|                    d| j                    |                    d| j!                   | "                    |           | _#        |                    d| j$                   t          j%        | _&        t          j'        | _(        t          j)        | _*        ddl+m,} t[          | d|j.        |j/                  | _)        ta          | d|j.        |j/                  | _%        ta          | d|j.        d          | _'        ta          | d|j.        |j/                  | _1        t           s3| j%        t          _%        | j'        t          _'        | j)        t          _)        	 dd l2}|j3        |_4        n#  t          j5        t          _'         xY w| 6                    | j                  | _7        d| _8        | 9                    |           | _	        | j:        j;        j        | j        _        | j:        <                    t{                                 d S )Nr   r   shell)r  She_llF   ps1z>>>
r   r2   char)wrapz<<newline-and-indent>>z<<plain-newline-and-indent>>z<<interrupt-execution>>z<<end-of-file>>z<<open-stack-viewer>><<toggle-debugger>>r^  r  z<<view-restart>>z<<restart-shell>>r  )iomenur   r  r  backslashreplacer  2   )>r  
menu_specsrv   r   rr   Tkr   withdrawr   shell_sidebarr   rI   usetabsindentwidthhasattrr   r  sys_ps1r  prompt_last_linepromptrJ   	configurerK   enter_callbacklinefeed_callbackcancel_callbackeof_callbackr  toggle_debuggertoggle_jit_stack_viewercopy_with_prompts_callbackview_restart_markrestart_shellr  squeezersqueeze_current_text_eventr  save_stdoutr  save_stderrr   
save_stdinr  r  r   encodingerrorsr   r  pydoc
plainpagerpagerri  r  historyrl  r  perr   insertfilterr   )rF   rN   msr   rJ   r  r  s          r(   rI   zPyShell.__init__r  s    	2B!uQx7""		!0111)$//=44D$MMOOO#D))E!dE4666")#u"5"5Bsww7 $ 2 24 8 8 <lyF###		*D,?@@@		0$2HIII		+T-ABBB		#T%6777		)4+ABBB		')=>>>		/1MNNN		)4+JKKK 	?II($*@AAAII)4+=>>>d++		,1	3 	3 	3 ::)""""""!$"(/6=B B
#D($*OV]D D#D($*O5GI I$T9%+_fmE E 	#CJCJ
CI	LLL*EKK	CJ||DI..!..t44
  8<.	799:::::s   ,M= =Nc                     t                                                       | j        | j                                         d S d S rC   )r   	ResetFontr  update_fontrF   r   s    r(   r	  zPyShell.ResetFont  sE    )**,,,,, *)r0   c                    t                                                       t          j                    }d d dt          j        |d          t          j        |d          t          j        |d          d}|                                D ]\  }} | j        j        |fi | | j        | j        	                                 d S d S )N)rd   rc   r  r  r|  )r   r  r  r  )
r   ResetColorizerr   rf   rg   itemsrJ   tag_configurer  update_colors)rF   rj   
tag_colorsr   tag_colors_configr   s        r(   r  zPyShell.ResetColorizer  s       %''"&d;;)%::)%::*5(;;	
 

 '1&6&6&8&8 	> 	>"C"#DI#C==+<====),,..... *)r0   c                 <    t          j         | j        d           dS )Nr   )insert_tagsra   )r   rJ   r   s     r(   replace_eventzPyShell.replace_event  s    	w7777wr0   c                 ,    t          j        d          S )NT)
shell_only)r   GetExtensionsr   s    r(   get_standard_extension_namesz$PyShell.get_standard_extension_names  s    %6666r0   c                 b     j                             ||          }t          t          t	          |                    t          t	          |                              } fd|D             }d                    d t          ||                                          D                       dz   S )z6Return text between first and last with prompts added.c                 N    g | ]!}j         j                            |          "S r   )r  line_promptsget)r  r'   rF   s     r(   r	  z+PyShell.get_prompt_text.<locals>.<listcomp>  s=     
 
 
 +//77
 
 
r0   r   c              3   2   K   | ]\  }}||n| d| V  d S )N r   )r  r  r   s      r(   	<genexpr>z*PyShell.get_prompt_text.<locals>.<genexpr>  sP       
 
 NDD6(:(:D(:(:
 
 
 
 
 
r0   )rJ   r  r   rx   ry   rR   zip
splitlines)rF   firstlastrJ   lineno_rangepromptss   `     r(   get_prompt_textzPyShell.get_prompt_text  s    y}}UD))ed 
 
 
 
&
 
 
 yy 
 
 #GT__->-> ? ?
 
 
 
 
  	r0   c                 0   | j         }|                    d          }|dS |                    d          }|d         dk    r|                    d          }|                                 |                     ||          }|                    |           dS )a  Copy selected lines to the clipboard, with prompts.

        This makes the copied text useful for doc-tests and interactive
        shell code examples.

        This always copies entire lines, even if only part of the first
        and/or last lines is selected.
        zsel.first linestartNsel.lastr2   0zsel.last+1line linestart)rJ   rn   clipboard_clearr'  clipboard_append)rF   rz   rJ   selfirstsellastprompt_texts         r(   r  z"PyShell.copy_with_prompts_callback  s     y::344F**Z((2;#jj!;<<G**8W==k*****r0   c                 
    |a d S rC   r    )rF   streams     r(   set_warning_streamzPyShell.set_warning_stream	  s    r0   c                     t           S rC   r1  r   s    r(   get_warning_streamzPyShell.get_warning_stream  s    r0   c                    | j         r2t          j        dd| j                   |                                  dS | j                                        }|r|                                  d S |                                  d S )NzDon't debug nowz*You can only toggle the debugger when idler  ra   )	r;  r
   r   rJ   set_debugger_indicatorrr   r7  close_debuggeropen_debugger)rF   rz   dbs      r(   r  zPyShell.toggle_debugger  s    > 	% !2<y" " " " '')))7((**B %##%%%%%""$$$$$r0   c                 h    | j                                         }|                     d|             d S )Nr  )rr   r7  setvarrF   r:  s     r(   r7  zPyShell.set_debugger_indicator  s4    [$$&&)2v:66666r0   c                     d S rC   r   r   s     r(   r  zPyShell.toggle_jit_stack_viewer"  s    r0   c                    | j                                         }|r| j                             d            |                                 | j         j        rt          j        | j         j                   |                                  | j        	                    d           | j
        | _        |                                  |                                  d S )Nz[DEBUG OFF]
)rr   r7  rs  r9  r!  r   close_remote_debuggerrd  r  r!   r  r  r?  r7  r=  s     r(   r8  zPyShell.close_debugger%  s    [$$&& 	K##D)))HHJJJ{! E01CDDDL///,DKOO##%%%%%r0   c                 P   | j         j        r t          j        | j         j        |           }nt	          j        |           }| j                             |           |                                 d| j        z   | _	        | 
                                 |                                  d S )Nz[DEBUG ON]
)rr   r!  r   start_remote_debuggerr   Debuggerrs  rA  r  r  r?  r7  )rF   dbg_guis     r(   r9  zPyShell.open_debugger2  s    ; 	. 6t{7I;?A AGG '--G(((  """$t|3##%%%%%r0   c                 J    | j         rdnd}|                     dd|           d S )Ndisabledr|  rs   z*tack*iewer)r;  update_menu_state)rF   states     r(   debug_menu_postcommandzPyShell.debug_menu_postcommand>  s0    "n:

(wu=====r0   c                 <    |                                   d| _        dS )Helper for ModifiedInterpreterTN)rd  r;  r   s    r(   r  zPyShell.beginexecutingB  s    r0   c                 J    d| _         d| _        |                                  dS )rK  FN)r;  r  r?  r   s    r(   rj  zPyShell.endexecutingG  s&    r0   c                     | j         r#t          j        ddd| j                  }|du rdS |                                  d| _        d| _        t          j        |           S )zExtend EditorWindow.close()zKill?z7Your program is still running!
 Do you want to kill it?okr  FcancelT)	r;  r
   askokcancelrJ   r<  r  rc  r   r9  )rF   rn  s     r(   r9  zPyShell.closeM  st    > 	 !-Jy	" " "H
 5  x!$'''r0   c                 >   |                                   t          r| j                                         | j        t
          _        | j        t
          _        | j	        t
          _
        d| _        d| _        d| j        _        d| _        t          j        |            dS )zEExtend EditorWindow._close(), shut down debugger and execution serverN)r8  r  rr   rS  r  r   r  r  r  r  r   r  rN   rq   r  r   r   r   s    r(   r   zPyShell._close\  s     	*K'')))%
%
O	!
D!!!!!r0   c                     dS )z8Override EditorWindow method: never remove the colorizerTr   r  s     r(   ispythonsourcezPyShell.ispythonsourcel  s    tr0   c                     | j         S rC   )shell_titler   s    r(   short_titlezPyShell.short_titlep  s    r0   zHType "help", "copyright", "credits" or "license()" for more information.c           
         | j                             dd           |                                  t          r4d}| j                                        }|s|                                  dS nd}t          j        t          _        | 
                    dt          j        dt          j        d| j        d|           | j                                          |                                  d	d l}d
|_        d |_        d
S )Nr   rv   rb   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 z on r   r   T)rJ   r=  rd  r  rr   r2  r9  r   displayhookr   r!   versionplatform	COPYRIGHTfocus_forcer?  tkinter_support_default_root_default_root)rF   nosubclientr]  s       r(   r   zPyShell.beginv  s    	8X... 	.E[1133F 

u'E "oCO


KKKt~~~uuF 	G 	G 	G	(,% $tr0   c                 X    | j         sd S d| _        | j                                         d S NT)reading_stop_readline_flagr   quitr   s    r(   r<  zPyShell.stop_readline  s,    | 	F#' r0   c                 ~   | j         }	 d| _         | j                                         || _         n# || _         w xY w| j        r	d| _        dS | j                            dd          }t          |          dk    rd}|                                  | j        rd| _        t          st          | j        r	d| _        d}|S )NTFrb   r   r4  r   r   )rd  r   mainloopre  rJ   r  r   rd  r  r  rb  	endoffile)rF   r:   r   s      r(   readlinezPyShell.readline  s    |	 DLHDLL4DL# 	',D$2y}}Xx00t99>>D= 	(!DM! (''> 	"DNDs    1 	:c                     dS rc  r   r   s    r(   isattyzPyShell.isatty  s    tr0   c                    	 | j                             ddd          rd S n#  Y nxY w| j        sK| j        sD|                                  | j                            d           |                                  dS d| _        d| _	        | j        rX| j        j
        rL| j                                        r| j                                         n| j                                         | j        r| j                                         dS )N	sel.firstz!=r)  zKeyboardInterrupt
ra   FT)rJ   r   r;  rd  rd  rr   r!   r?  ri  r  r!  r7  rC  rO  r   rf  r   s     r(   r  zPyShell.cancel_callback  s   	y  dJ?? 	D 	$, 	K3444OO7N 	3t{1 	3{&&(( 3..000000222< 	HMMOOOws   ! %c                 H   | j         r	| j        sd S | j                            ddd          r| j                            ddd          sd S | j         s)|                                  |                                  n'd| _        d| _        | j        	                                 dS )Nr   z==rv   r4  FTra   )
r;  rd  rJ   r   rd  r9  r  ri  r   rf  r   s     r(   r  zPyShell.eof_callback  s    > 	$, 	F	!!(D(;; 		!!(D(;;	F~ 	JJLLLL!DM!DNHMMOOOwr0   c                     | j         r6| j                            dd           | j                            d           n|                     |           dS )Nrv   r   ra   )rd  rJ   rv   seenewline_and_indent_eventr   s     r(   r  zPyShell.linefeed_callback  sT    < 	1IXt,,,IMM(####))%000wr0   c                 	   | j         r	| j        sd S 	 | j                            dd          }|r4| j                            ddd          r|                     ||           dS n#  Y nxY w| j                            ddd          r| j                            d	d          }|rB| j                            dd|d
                   rd| j                            d          vr| j                            dd          }|r8| j                            |d
         d|d                   r|d
         |d
         f}| j                            dd          }|rS| j                            |d         d|d
                   r+|d         | j        	                    |d         dz             f}|                     | j                            |d         |d
                   |           dS | j                            d	d          }|r| j                            dd|d                   r| j                            dd          }|rS| j                            |d         d|d
                   r+|d         | j        	                    |d         dz             f}|                     | j                            |d         |d
                   |           dS | j                            dd          }|rX| j                            |d         dd          r6|                     | j                            |d
         d          |           n/|                     | j                            dd          |           dS | j                            ddd          r| j        
                    dd           | j                            dd          }|r/|                                s| j                            dd           | j                            ddd          r|                     |           dS | j        
                    dd           | j        r6| j                            dd           | j                            d           n|                     |           | j                                         | j        r| j                                         n|                                  dS )Nrn  r)  z<=r   ra   rv   r   iomark linestartr   r   r  z>=r   z+1czinsert lineendr|   r4  zend-1c linestartr   )r;  rd  rJ   r  r   recalltag_prevrange	tag_namestag_nextrangern   r=  stripr   rr  rv   rq  update_idletasksr   rf  runit)	rF   rz   selprev	prev_cons	next_consnextindicesr  s	            r(   r  zPyShell.enter_callback  s   > 	$, 	F	)--Z88C #9$$Zx@@ #KKU+++"7	D 9Xs,>?? "	
 9**7H==DI%%hT!W== TY%8%8%B%BBB I33IxHH	 3!2!29Q<tAw!O!O 3%aL$q'2D I33IxHH	 L!2!29Q<d1g!N!N L GTY__Yq\E5I%J%JKDDIMM$q'47;;UCCCw9**7H==D 	))*:D$q'JJ  I33I?OPP	 L!2!29Q<d1g!N!N L GTY__Yq\E5I%J%JKDDIMM$q'47;;UCCCwi--i9KLLG Xy  T3EFFXDIMM'!*6FGGOOOODIMM*<>NOOQVWWW7 9XsH55 	3Ix222 IMM(H-- 	1QWWYY 	1IXx000 9Xs,>?? 	))%0007	8X...< 	1IXt,,,IMM(####))%000	""$$$< 	HMMOOOOJJLLLws   AA$ $A(c                    t          j        dd|          }t          j        dd|          }|                    d          }| j                                         	 | j                            ddd           | j                            dd	           | j                            d
d          }|                                	                    d          r0| 
                    |           | j                            d
d          }| j                            d|d                                         | j                   t          |          dk    rt          j        d|d                                       d          }t          j        d|                              d          }|dd          D ]g}|                    |          r||t          |          d          z   }| j                            dd|                                z   | j                   h| j                            d           | j                                         d S # | j                            d           | j                                         w xY w)Nz^\s*\nrb   z\n\s*$r   r|  r   r   rv   r4  r|   :r   r   z	^([ \t]*))resubr  rJ   undo_block_startr~   r=  r  rstripendswithrr  rv   ry  user_input_insert_tagsr   searchgroupr   rq  undo_block_stop)rF   r  rz   r   prefixorig_base_indentnew_base_indentr   s           r(   ru  zPyShell.recall-  sM   F9b!$$F9b!$$	""$$$	(I  u555Ix222Y]]#5x@@F}}'',, E--e444'98DDIXuQx~~'7'7!8: : :5zzA~~#%9\58#D#D#J#J1#M#M #%9\6#B#B#H#H#K#K!!""I B BD'788 N.c:J6K6K6L6L1MMI$$Xtdkkmm/C%)%@B B B B IMM(###I%%''''' IMM(###I%%''''s   F=I 5Jz[ \t]*(\n[ \t]*)?\Zc                    | j                             d          }| j                             dd          }| j                            d|          }| j                            |          }|sY| j                             |          dk    r | j                             | j        |           | j	        
                                 d S d S )Nend-2cr   r4  rb   r   )rJ   rn   r  _last_newline_rer  rr   r  r~   r  r  update_sidebar)rF   index_beforer   input_is_completes       r(   r{  zPyShell.runitJ  s    yx00y}}Xx00 $((T22 K11$77  	0y}}\**d22	$$T%@,OOO--/////	0 	0r0   c                     | j         j        r| j                                         S ddlm} 	  || j        t          j        | j                   n##  t          j
        dd| j                   Y nxY wd S )Nr   )StackBrowserzNo stack tracez<There is no stack trace yet.
(sys.last_value is not defined)r  )rr   r!  rh  idlelib.stackviewerr  r   r   
last_valuerN   r
   r   rJ   )rF   rz   r  s      r(   r  zPyShell.open_stack_viewerV  s    ; 	5;22444444444	"LCNDJ????	" !12y" " " " " " ts   !A A/c                 n    | j                             d           | j                             d           d S )Nr   r5  )rJ   rq  r   s     r(   r  zPyShell.view_restart_markd  s0    	h	i     r0   c                 <    | j                             d           dS )z&Callback for Run/Restart Shell Cntl-F6Tr  N)rr   rC  r   s     r(   r  zPyShell.restart_shellh  s!    &&&55555r0   c                    |                                   | j        }| j        r7|                    | j                  r|d t	          | j                            }| j                            dd           | j                            |           | j	        
                                 | j                            dd           |                                  | j                                         d S )Nr  z	iomark-1crv   r4  )rd  r  r  r  r   rJ   rm   r  r!   r  r  r=  set_line_and_columnrU   
reset_undo)rF   r  s     r(   r?  zPyShell.showpromptl  s    < 	1FOODL99 	1/c$,////0F	)[1116"""))+++	8X...  """r0   c                    | j         j        j        }t          |dd          }d                    |                    |                    }|                    d          s|dz  }| j        j        	                    d|d           d S )N   T)r   tabsizeexpand_tabsr   rt  r  )
rr   r   r   r   rR   r  r  r  bottomrv   )rF   r  r   wrapperwrapped_msgs        r(   show_warningzPyShell.show_warningz  s    %+E1$GGGiiS 1 122##D)) 	 4K1;IIIIIr0   c                    | j                             dd          }| j        r| j                            |           | j                             d          dk    r| j                             dd           | j                             dd           |                                  | j                                         d S )Nr   r4  r  r   )	rJ   r  r  storerv   r=  r  ctipremove_calltip_window)rF   r  s     r(   rd  zPyShell.resetoutput  s    x22< 	'Lv&&&9==""d**IXt,,,	8X...  """	'')))))r0   r   c                     	 | j                             dd           t          j        | ||d          }| j                             dd           n#   xY w| j        rd| _        t
          st          |S )Nr   rightr6  F)rJ   r>  r   r!   r  r  rb  )rF   r  r   counts       r(   r!   zPyShell.write  s    	I""8W555 &tQh??EI""8V4444	= 	(!DM! (''s   AA Ac                     	 | j                             ddd          rdS n# t          $ r Y dS w xY wt                                                      S )Nrn  r   r   rF  )rJ   r   r   r   r[   r  s    r(   r[   zPyShell.rmenu_check_cut  sf    	y  c8<< "!z" 	 	 	::	ww&&(((s   " 
00c                     | j                             ddd          rdS t                                                      S )Nrv   r   r   rF  )rJ   r   r   r_   r  s    r(   r_   zPyShell.rmenu_check_paste  s:    9Xc(33 	:ww((***r0   c                 j    | j                                          | j                                         d S rC   )r  squeeze_current_textr  r  r   s     r(   r  z"PyShell.squeeze_current_text_event  s1    **,,,))+++++r0   c                 8    | j                                          d S rC   )r  r  )rF   rn   rJ   r   s       r(   on_squeezed_expandzPyShell.on_squeezed_expand  s    ))+++++r0   rC   )r   )Or   r   r   idlelib.squeezerr  r   rU  r   r   r   r   r  r   r   r   r6   	itertools	takewhile_idxrv   allow_line_numbersr  idlelib.historyr  idlelib.sidebarr  rI   r	  r  r  r  r'  r  rd  r;  r  ri  rc  re  r3  r5  r  r7  r  r8  r9  rI  r  rj  r9  r   rS  rV  r[  r   r<  rj  rl  r  r  r  r  ru  r  r   r  r{  r  r  r  r?  r  rd  r!   r[   r_   r  r  r   r   s   @r(   r   r   L  s0       )))))).."2"22K ,N)M  J */. K ss44+	+22KA A     D t 2 3 3 3 	$ (''''',,,,,,L; L; L; L;\- - - - -/ / / / /   7 7 7  "+ + + +( GIHIG       % % % %7 7 7   & & &
& 
& 
&> > >  
  ( ( (" " "         U   4    .     ,    M M M^( ( (8 "rz"899
0 
0 
0   ! ! ! !6 6 6 6  J J J* * *   ) ) ) ) )+ + + + +
, , , ,, , , , , , ,r0   r   c           
          | j         dk    r3dD ]2}|                     |dd|                     |d          z              1dS dS )z6Make paste replace selection on x11.  See issue #5124.x11)TextEntrySpinboxz	<<Paste>>z%catch {%W delete sel.first sel.last}
N)_windowingsystem
bind_class)r   clss     r(   fix_x11_paster    sk    %%- 	; 	;COO8[99:; ; ; ; &%	; 	;r0   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                     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}		 |                      t          j	        dd          d          \  }
}nQ# | j
        $ rD}t          d	| d
t           t          j                   t          j        d           Y d }~nd }~ww xY w|
D ]\  }}|dk    r|}d}|dk    rd}d}|dk    rd}|dk    r7t          j                            t                     t          j                     |dk    rd}|dk    rt          dt          j                   da|dk    rG|}t"          j                            |          rn#t          d|           t          j                     d}|dk    rd}	d}|dk    r|t(          _        d}|r,|d         dk    r t          j                                        }d}t1          t3          t          j                            D ]>}t"          j                            t          j        |                   t          j        |<   ?|r%|d         dk    rdg|dd          z   t          _	        n|rdg|z   t          _	        n|r|g|z   t          _	        n|rd}g }|D ]4}|                    t"          j                            |                     5|D ]O}t"          j                            |          }|t          j        vr t          j                            d|           PnAt#          j                    }|t          j        vr t          j                            d|           t?          j         dddd          }|p|}|p| }t          r|stC                       tE          d           a#tF          $                                 dd!l%m&}  |tF                     t"          j        '                    t"          j                            tP                    d"           |            d#k    r<t"          j        '                    d$          }tF          )                    |%           nU|*                                sAtV          d&k    rd'd(}nd)d*}fd+|D             }d, |D             }tG          j,        dg|R   t[          tF                     t]          tF                     t_          tF                    a0|1                    tF          t`                     |r[|sY|sW|d d          D ]1}t`          2                    |          |3                    |           2|st`          4                                 |rWt`          5                                }|sd S |*                                r%t`          j6        r|j7        8                                 nt`          j9        }|r|:                                 |	ryt"          j;        <                    d-          pt"          j;        <                    d.          }|r9t"          j                            |          r|j=        >                    |           |s|r|j=        ?                    d/@                    t          j	                             |r|j=        A                    |           nd|r4|j=        B                    |           |j=        >                    |           n-|r+|C                                }|r|D                    |           t`          jE        r%tF          F                                 t`          jE        %tF          G                                 t          d           d S )0Nr   )system)testing)macosxTFr   zc:deihnr:st:zError: r   r   r   r  z-dz-ez-hz-iz-nz: Warning: running IDLE without a subprocess is deprecated.z-rzNo script file: z-sz-t-rb   r
  r  zeditor-on-startupr  )r  Idle)	className)fix_scalingIconsWindowszidle.ico)r  g333333!@z.png)       0      z.gif)r  r  r  c                 Z    g | ]'}t           j                            d |fz            (S )z	idle_%d%s)rP   rQ   rR   )r  sizeexticondirs     r(   r	  zmain.<locals>.<listcomp>Y  sB     ( ( ( W\\';$+DEE ( ( (r0   c                 :    g | ]}t          t          |           S ))masterr   )
PhotoImager   )r  iconfiles     r(   r	  zmain.<locals>.<listcomp>[  s5     , , , 4h777 , , ,r0   IDLESTARTUPPYTHONSTARTUPzdif 1:
            import sys as _sys
            _sys.argv = {!r}
            del _sys
            
)HgetoptrZ  r  r  r  r  r/   r  r   argverrorre  	usage_msgr  exitr  r!   rP   rQ   r   r   rU  r   r  r   r   r  rp   dirnamerv   getcwdr   r  NoDefaultRootr  r   r  idlelib.runr  rR   __file__wm_iconbitmapisAquaTk	TkVersionwm_iconphotor   r  r   rN   setupAppr   r}   newrO   dictr   lowerrq   r9  environr  rr   r  rY  rZ  r  r  preferTabsPreferenceWarningr  inversedictrh  destroy)r  r  r  r  enable_shellenable_editrs   cmdscriptstartupoptsrY   r  oar1  pathxr&   dir
edit_startr  r  sizes	iconfilesiconsr  prefer_tabs_preference_warningr  r  s                              @@r(   r
  r
    s   MMM TNLKE
CFG]]38ABB<@@
dd<   ***y**<<<<     199CL99EL99K99JY'''HJJJ99L99Nz# # # #"N99Fw~~f%% (&111


L99GL99"#GL Q3inn3sx==!! 3 3goochqk22 $Q34$qrr(?	 $6D=	 $8d?	 $ 	4 	4HLL223333 	( 	(C'//#&&C#(??3'''	(
 ikkchHOOAs####FI$7fF F FJ+K2{?L  g DMMOOO''''''K gll27??844g>>Gvxx97<<448,,,,__ (C%EEC E( ( ( ( (!&( ( (	, ,!*, , ,$''''' $$D!!E
OOD%     	v 	 G * *::h''/KK))) 		   "" 	F?? 	 	
 IOO   ,:>>-00 3:>>/22 	 	,x00 	,L!!(+++
 ?f ? ! &""		$ 	$ 	$
  	*L##C(((( 	*L((000L!!&)))	 
? *0)K)K)M)M&) 	?=>>>

  
 LLNNNUs   +A# #
B1-:B,,B1)NN)Rr   r   r   r]  ImportErrorre  ri  r  rZ  ctypesPROCESS_SYSTEM_DPI_AWAREOleDLLSetProcessDpiAwarenessr"   r#   r
   r  r   r  r4   rP   os.pathr   r  r&  r  textwrapr   rK  r  r  r,   idlelib.colorizerr   idlelib.configr   idlelib.delegatorr   r  r   r   idlelib.editorr   r   idlelib.filelistr   idlelib.outwinr   r   r   r  r   r   r   idlelib.undor   r  r  r   eofr  rf  	NameErrorr    r)   r+   r/   
checkcacher<   r>   r   r   r   r   	RPCClientr   r   r   r   r  r  r
  r   r0   r(   <module>r     s:   


z%([%<CK!"   	E 9?B~O O O O
*Q-- <7#$ h667OPPPP1          ' ' ' ' ' '         				  # # # # # # 				                         , , , , , , # # # # # # ' ' ' ' ' '             6 6 6 6 6 6 6 6 % % % % % % ' ' ' ' ' '             G G G G G G G G G G & & & & & & 	
 CDHDHH 	 	 	D	  >B   "  ) ) )     +/2;2F   ( 5	 {" {" {" {" {", {" {" {"|    h   (
2 
2 
2 
2 
2^ 
2 
2 
2/ / / / /M / / /D1 1 1 1 1	 1 1 1    #-     j( j( j( j( j(0 j( j( j(Z`	, `	, `	, `	, `	,l `	, `	, `	,F; ; ;4	ln n n` zDFFF       s-   & #A	)B BB)D: :EE