
    Mh              	          d Z ddlZddlZddlZddlmZ daej        dk    rd Z	nej
        dk    rd Z	nd	 Z	d
 Zd Zd Zdad Zd Zej        dk    r5ej                            dd          Ze                    d          reZeZn0ej
        dk    r%ddlZej        j        j        Zej        ge_        d Zd Zd Zddededeeef         fdZdS )z
Utilities for working with terminals.

Authors:

* Brian E. Granger
* Fernando Perez
* Alexander Belchenko (e-mail: bialix AT ukr.net)
    N)get_terminal_sizeTposixc                  .    t          j        d           d S )Nclearossystem     V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/IPython/utils/terminal.py_term_clearr      s    
	'r   win32c                  .    t          j        d           d S )Nclsr   r
   r   r   r   r      s    
	%r   c                      d S Nr
   r
   r   r   r   r       s    r   c                     |  a dS )a  Control whether set_term_title is active or not.

    set_term_title() allows writing to the console titlebar.  In embedded
    widgets this can cause problems, so this call can be used to toggle it on
    or off as needed.

    The default state of the module is for the function to be disabled.

    Parameters
    ----------
    val : bool
        If True, set_term_title() actually writes to the terminal (using the
        appropriate platform-specific module).  If False, it is a no-op.
    N)ignore_termtitle)vals    r   toggle_set_term_titler   %   s      xr   c                      dS )zDummy no-op.Nr
   )argskws     r   _set_term_titler   8   s    Dr   c                      d S r   r
   r
   r   r   _restore_term_titler   =   s    Dr   Fc                     t           s!t          j                            d           da t          j                            d| z             dS )z3 Change virtual terminal title in xterm-workalikes z[22;0tTz]0;%sN)_xterm_term_title_savedsysstdoutwritetitles    r   _set_term_title_xtermr$   D   sI    
 # '
&&&"&J_u,-----r   c                      t           st          j        dd           d S t          j                            d           da d S )NzYExpecting xterm_term_title_saved to be True, but is not; will not restore terminal title.   )
stacklevelz[23;0tF)r   warningswarnr   r    r!   r
   r   r   _restore_term_title_xtermr*   P   sT     # g	
 	
 	
 	
 	J\"""#r   TERM xtermc                 $    t          |            dS )z9Set terminal title using ctypes to access the Win32 APIs.N)SetConsoleTitleWr"   s    r   r   r   i   s    r   c                 6    t           rdS t          |            dS )z@Set terminal title using the necessary platform-dependent calls.N)r   r   r"   s    r   set_term_titler1   n   s#     Er   c                  4    t           rdS t                       dS )z:Restore, if possible, terminal title to the original stateN)r   r   r
   r   r   restore_term_titler3   u   s!     r   P      defaultxdefaultyreturnc                 $    t          | |f          S r   )_get_terminal_size)r6   r7   s     r   r   r   |   s    x2333r   )r4   r5   )__doc__r   r   r(   shutilr   r:   r   namer   platformr   r   r   r   r$   r*   environgetr+   
startswithctypeswindllkernel32r/   	c_wchar_pargtypesr1   r3   inttupler
   r   r   <module>rI      s    
			 



  : : : : : :   7g   \W     
     &	 	 	
	 	 	   	. 	. 	.$ $ $ 7g:>>&$$Dw 8/7\WMMM}->!'!1 2     
    4 4 4C 4sCx 4 4 4 4 4 4r   