
    F\h                        S SK Jr  S SKrS SKJrJr  S SKrS SKrS SKrS SK	J
r
Jr  S SKrS SKrSr\(       a  S SKJr  S SKJr  \
 " S S	5      5       r\
 " S
 S\5      5       r " S S\R*                  5      rg)    )annotationsN)ABCabstractmethod)	dataclassfieldF)IO)Callablec                  8    \ rS rSr% S\S'   S\S'   SrS\S'   Srg	)
Event(   strevtdata    bytesraw N)__name__
__module____qualname____firstlineno____annotations__r   __static_attributes__r   r   &/usr/lib/python3.13/_pyrepl/console.pyr   r   (   s    	H
ICr   r   c                     \ rS rSr% S\S'   \" \S9rS\S'   SrS\S	'   S
r	S\S'       S        S!S jjr
\S"S j5       r\S#S j5       r\S#S j5       r\S$S j5       r\S%S j5       r\S&S j5       r\S'S(S jj5       r\S)S j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S#S j5       r\S*S j5       r\S+S j5       r\S,S j5       r\S#S j5       rSrg)-Console/   tuple[int, int]posxy)default_factory	list[str]screen   intheightP   widthc                   U=(       d    [         R                  " 5       U l        [        U[        5      (       a  Xl        OUR                  5       U l        [        U[        5      (       a  X l        g UR                  5       U l        g N)sysgetdefaultencodingencoding
isinstancer$   input_fdfileno	output_fd)selff_inf_outtermr,   s        r   __init__Console.__init__6   sW     !<C$:$:$<dC   M KKMDMeS!!"N"\\^DNr   c                    g r)   r   )r1   r"   xys      r   refreshConsole.refreshI   s    GJr   c                    g r)   r   r1   s    r   prepareConsole.prepareL       "r   c                    g r)   r   r<   s    r   restoreConsole.restoreO   r?   r   c                    g r)   r   )r1   xys      r   move_cursorConsole.move_cursorR   s    36r   c                    g r)   r   )r1   visibles     r   set_cursor_visConsole.set_cursor_visU   s    58r   c                    g)zlReturn (height, width) where height and width are the height
and width of the terminal window in characters.Nr   r<   s    r   getheightwidthConsole.getheightwidthX        	r   c                    g)zReturn an Event instance.  Returns None if |block| is false
and there is no event pending, otherwise waits for the
completion of an event.Nr   )r1   blocks     r   	get_eventConsole.get_event^       
 	r   c                    g)z.
Push a character to the console event queue.
Nr   )r1   chars     r   	push_charConsole.push_chare   rT   r   c                    g r)   r   r<   s    r   beepConsole.beepl   s    r   c                    g)zWipe the screenNr   r<   s    r   clearConsole.clearo        	r   c                    g)zsMove the cursor to the end of the display and otherwise get
ready for end.  XXX could be merged with restore?  Hmm.Nr   r<   s    r   finishConsole.finisht   rO   r   c                    g)zTFlush all output to the screen (assuming there's some
buffering going on somewhere).Nr   r<   s    r   flushoutputConsole.flushoutputz   rO   r   c                    g)z0Forget all pending, but not yet processed input.Nr   r<   s    r   forgetinputConsole.forgetinput   r_   r   c                    g)zAReturn the characters that have been typed but not yet
processed.Nr   r<   s    r   
getpendingConsole.getpending   rO   r   c                    g)zWait for an event. The return value is True if an event is
available, False if the timeout has been reached. If timeout is
None, wait forever. The timeout is in milliseconds.Nr   )r1   timeouts     r   waitConsole.wait   rT   r   c                    g)zReturns the current input hook.Nr   r<   s    r   
input_hookConsole.input_hook   r_   r   c                    g r)   r   r<   s    r   repaintConsole.repaint   r?   r   )r,   r.   r0   N)r       rw   )r2   IO[bytes] | intr3   rx   r4   r   r,   r   )r"   r!   r8   r   returnNone)ry   rz   )rD   r$   rE   r$   ry   rz   )rI   boolry   rz   )ry   r   )T)rQ   r{   ry   zEvent | None)rV   zint | bytesry   rz   )ry   r   )rm   zfloat | Nonery   r{   )ry   zCallable[[], int] | None)r   r   r   r   r   r   listr"   r%   r'   r5   r   r9   r=   rA   rF   rJ   rM   rR   rW   rZ   r]   ra   rd   rg   rj   rn   propertyrq   rt   r   r   r   r   r   r   /   s   d3FI3FCE3O !"!",, , 	,
 ,& J J" "" "6 68 8 
         
  
    
     " "r   r   c                  ~   ^  \ rS rSr\" 5       r  S
SS.       SU 4S jjjjrSU 4S jjrS rS r	SS jr
S	rU =r$ )InteractiveColoredConsole   F)
local_exitc               V   > [         TU ]  XUS9  [        R                  " 5       U l        g )N)localsfilenamer   )superr5   	_colorizecan_colorize)r1   r   r   r   	__class__s       r   r5   "InteractiveColoredConsole.__init__   s(     	jQ%224r   c                *   > [         TU ]  " SSU0UD6  g )Nr   r   )r   showsyntaxerror)r1   r   kwargsr   s      r   r   )InteractiveColoredConsole.showsyntaxerror   s    <<V<r   c                    SS K nUR                  XUU R                  UR                  S9nU R	                  SR                  U5      5        g )Nr   )colorizelimitrw   )	tracebackformat_exceptionr   BUILTIN_EXCEPTION_LIMITwritejoin)r1   typvaluetbr   liness         r   _excepthook%InteractiveColoredConsole._excepthook   sG    **B**77 + 9 	

2775>"r   c                     [        XR                  5        g ! [         a    e [         a    U R	                  5         U R
                  s $ f = fr)   )execr   
SystemExitBaseExceptionshowtracebackSTATEMENT_FAILED)r1   codes     r   runcode!InteractiveColoredConsole.runcode   sL    	){{#   	 	) (((	)s    0A
Ac                n    U R                   R                  UUS[        R                  SS9nUR                  (       a  UR                  Gt pVUR                   H  nUWL a  [        R                  O[        R                  nXvL a  UOSn	U" U/5      n
 U R                   R                  XU	5      n[        R                  " XU5        Uc    g	U R)                  U5      nXR*                  L d  M    g   g! [        [
        [        4 a    U R                  X!S9   gf = f! [         ao  nUR                  S   S:X  aB  [        R                  R!                  ["        R$                  5      nUR'                  SU S35        U R                  X!S9   S nA  gS nAf[
        [        4 a    U R                  X!S9     gf = f)
Nr   F)incomplete_input)sourcer   z'await' outside functionzTry the asyncio REPL (zG -m asyncio) to use top-level 'await' and run background asyncio tasks.T)compilecompilerastPyCF_ONLY_ASTSyntaxErrorOverflowError
ValueErrorr   bodyInteractiveModule	linecache_register_codeargsospathbasenamer*   
executableadd_noter   r   )r1   r   r   symboltree_	last_stmtstmtwrapper
the_symbolitemr   epythonresults                  r   	runsource#InteractiveColoredConsole.runsource   s   
	<<((!!!& ) D 99 IIMQIID)-):coo

G#'#4&JD6?D||,,TZH((x@ |\\$'F...5 4 ? ]J7 	   9	  66!9 ::WW--cnn=FJJ0 9O P $$X$=!:. $$X$=s0   +C0 3D0$DD
F4$A$F"F43F4)r   )Nz	<console>)r   zdict[str, object] | Noner   r   r   r{   ry   rz   r)   )z<input>single)r   r   r   r   objectr   r5   r   r   r   r   r   __classcell__)r   s   @r   r   r      sf    x ,0#5
 !5(5 5
 5 
5 5=#( (r   r   )
__future__r   r   abcr   r   r   r   r   dataclassesr   r   os.pathr   r*   TYPE_CHECKINGtypingr   r	   r   r   InteractiveConsoler   r   r   r   <module>r      s~   ( #  # 
   (  
     h#c h# h#VJ 7 7 Jr   