403Webshell
Server IP : 3.96.16.70  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux ip-172-31-26-103.ca-central-1.compute.internal 6.1.163-186.299.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Feb 24 16:35:42 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3.9/site-packages/prompt_toolkit/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/prompt_toolkit/__pycache__/renderer.cpython-39.pyc
a

gaoo�@s�dZddlmZmZmZmZmZddlmZddl	m
Z
ddlmZm
Z
mZmZmZmZmZmZddlmZddlmZmZddlmZmZdd	lmZmZdd
lm Z ddl!m"Z"m#Z#m$Z$ddl%m&Z&m'Z'dd
l(m)Z)m*Z*m+Z+m,Z,e�rddl-m.Z.ddl/m0Z0ddgZ1de'e#ee&ee#ee2e3e3ddee4eeee2fd�dd�Z5Gdd�de6�Z7Gdd�dee2e)f�Z8Gdd�dee2e3f�Z9Gdd�de
�Z:Gdd�d�Z;d"e'ee*ee,ee&dd �d!d�Z<dS)#z_
Renders the command line on the console.
(Redraws parts of the input line that were changed.)
�)�FIRST_COMPLETED�Future�
ensure_future�sleep�wait)�deque)�Enum)�
TYPE_CHECKING�Any�Callable�Deque�Dict�Hashable�Optional�Tuple)�get_app)�Point�Size)�FilterOrBool�	to_filter)�AnyFormattedText�to_formatted_text)�
MouseHandlers)�Char�Screen�
WritePosition)�
ColorDepth�Output)�Attrs�	BaseStyle�DummyStyleTransformation�StyleTransformation)�Application)�Layout�Renderer�print_formatted_text�Application[Any]�_StyleStringToAttrsCache�_StyleStringHasStyleCache)�app�output�screen�current_pos�color_depth�previous_screen�
last_style�is_done�full_screen�attrs_for_style_string�style_string_has_style�size�previous_width�returnc
s�|j|j�}
|j�|j}|j�|j�|j�|j�|j�|�	�dd���fdd��	t
t
d������	��fdd�}tdd������fd	d
�}tt
tft
d��
fdd
�}|s��	�|r�|s�|��|s�|r�|�kr�|t
ddd����	�|��t�}t|j|
�}tt|j|j�|
�}d}t|�D�]}|j|}|j|}|j|}t�d||��}t�d||��}d}||k�r||}||}|j�p�d}|j|jk�s�|j|jk�r�|t
||d���||v�r�|||�||�t
�j|�jd��||7}�qr|�r&||k�r&|t
|d|d����	�|���q&||jk�rX|t
d|dd���|�rx|t
d|d���|��n||�|jj���|�s�|�s�|� ��	�|j!�s�|�r�|�!���fS)a�
    Render the diff between this screen and the previous screen.

    This takes two `Screen` instances. The one that represents the output like
    it was during the last rendering and one that represents the current
    output raster. Looking at these two `Screen` instances, this function will
    render the difference by calling the appropriate methods of the `Output`
    object that only paint the changes to the terminal.

    This is some performance-critical code which is heavily optimized.
    Don't change things without profiling first.

    :param current_pos: Current cursor position.
    :param last_style: The style string, used for drawing the last drawn
        character.  (Color/attributes.)
    :param attrs_for_style_string: :class:`._StyleStringToAttrsCache` instance.
    :param width: The width of the terminal.
    :param previous_width: The width of the terminal during the last rendering.
    N�r6cs��d�dS)z'Wrapper around Output.reset_attributes.N�r8)�_output_reset_attributesr/r8�;/usr/lib/python3.9/site-packages/prompt_toolkit/renderer.py�reset_attributesVsz-_output_screen_diff.<locals>.reset_attributes)�newr6cs��j�j}}|j|krB���d|j|�d}�|j�|S|j|krZ�||j�|�dkrz�d��|j�n>|j|ks�|�dkr��||j�n|j|kr��|j|�|S)z9Move cursor to this `new` point. Returns the given Point.�
r��
��x�y)r<Z	current_xZ	current_y)�_output_cursor_backward�_output_cursor_forward�_output_cursor_upr,r;�width�writer8r:�move_cursor\s"



z(_output_screen_diff.<locals>.move_cursor)�charr6csN�|jkr�|j�n4�|j}�r0|��kr:�|���|j�|j�dS)z5
        Write the output of this character.
        N)�stylerI)rIZ	new_attrs)�_output_set_attributesr2r-r/rGr8r:�output_charws



z(_output_screen_diff.<locals>.output_char��rowr6cs(�fdd�|��D�}|�d�t|�S)a6
        Return max used column index, ignoring whitespace (without style) at
        the end of the line. This is important for people that copy/paste
        terminal output.

        There are two reasons we are sometimes seeing whitespace at the end:
        - `BufferControl` adds a trailing space to each line, because it's a
          possible cursor position, so that the line wrapping won't change if
          the cursor position moves around.
        - The `Window` adds a style class to the current line for highlighting
          (cursor-line).
        cs(g|] \}}|jdks �|jr|�qS)� )rIrJ)�.0�indexZcell�r3r8r:�
<listcomp>�s�zE_output_screen_diff.<locals>.get_max_column_index.<locals>.<listcomp>r)�items�append�max)rNZnumbersrRr8r:�get_max_column_index�s

�
z1_output_screen_diff.<locals>.get_max_column_indexrr@r>)"�columns�rowsrG�	write_raw�set_attributesr;Zcursor_forward�	cursor_up�cursor_backwardZhide_cursorrrr
�intZdisable_autowrap�
erase_downr�min�heightrV�rangeZdata_bufferZzero_width_escapesrFrIrJrArBZerase_end_of_lineZget_cursor_position�layoutZcurrent_window�enable_autowrap�show_cursor)r)r*r+r,r-r.r/r0r1r2r3r4r5rarZrHrLrWZcurrent_heightZ	row_count�crBZnew_rowZprevious_rowZzero_width_escapes_rowZnew_max_line_lenZprevious_max_line_lenZnew_charZold_charZ
char_widthr8)
rCrDrEr9rKr2r-r,r/r;r3rFrGr:�_output_screen_diff#s�" ���





rgc@seZdZdZdS)�HeightIsUnknownErrorz>Information unavailable. Did not yet receive the CPR response.N)�__name__�
__module__�__qualname__�__doc__r8r8r8r:rhsrhc@s<eZdZdZedgefedd�dd�Zeed�dd	�Z	dS)
r'zk
    A cache structure that maps style strings to :class:`.Attr`.
    (This is an important speed up.)
    �strN)�get_attrs_for_style_str�style_transformationr6cCs||_||_dS�N)rnro)�selfrnror8r8r:�__init__sz!_StyleStringToAttrsCache.__init__��	style_strr6cCs"|�|�}|j�|�}|||<|Srp)rnroZtransform_attrs)rqrt�attrsr8r8r:�__missing__s
z$_StyleStringToAttrsCache.__missing__)
rirjrkrlrrr!rrrmrvr8r8r8r:r's�	c@s8eZdZdZeeefdd�dd�Zeed�dd�Z	dS)	r(a
    Cache for remember which style strings don't render the default output
    style (default fg/bg, no underline and no reverse and no blink). That way
    we know that we should render these cells, even when they're empty (when
    they contain a space).

    Note: we don't consider bold/italic/hidden because they don't change the
    output if there's no text in the cell.
    N)�style_string_to_attrsr6cCs
||_dSrp)rw)rqrwr8r8r:rr.sz"_StyleStringHasStyleCache.__init__rscCs>|j|}t|jp.|jp.|jp.|jp.|jp.|j�}|||<|Srp)rw�boolZcolorZbgcolorZ	underlineZstrikeZblink�reverse)rqrtruZ
is_defaultr8r8r:rv1s
�����	z%_StyleStringHasStyleCache.__missing__)
rirjrkrlr
rmrrrrxrvr8r8r8r:r(#s
c@seZdZdZdZdZdZdS)�CPR_Supportz&Enum: whether or not CPR is supported.�	SUPPORTED�
NOT_SUPPORTED�UNKNOWNN)rirjrkrlr{r|r}r8r8r8r:rz@srzc	@seZdZdZdZd(eeeee	e
gdfdd�dd�Zd)eedd	�d
d�Ze
e	ed�d
d��Ze
ed�dd��Ze
ed�dd��Zdd�dd�Zedd�dd�Ze
ed�dd��Zd*edd�dd�Zd+ddedd �d!d"�Zd,edd#�d$d%�Zdd�d&d'�ZdS)-r$z�
    Typical usage:

    ::

        output = Vt100_Output.from_pty(sys.stdout)
        r = Renderer(style, output)
        r.render(app, layout=...)
    �FN)rJr*r1�
mouse_support�cpr_not_supported_callbackr6cCs�||_||_||_t|�|_||_d|_d|_d|_d|_	t
�|_tj
|_|jsXtj|_d|_d|_d|_d|_d|_|jdd�dS)NFT)�_scroll)rJr*r1rrr��_in_alternate_screen�_mouse_support_enabled�_bracketed_paste_enabled�_cursor_key_mode_resetr�_waiting_for_cpr_futuresrzr}�cpr_supportZresponds_to_cprr|�_attrs_for_style�_style_string_has_style�_last_style_hash�_last_transformation_hash�_last_color_depth�reset)rqrJr*r1rr�r8r8r:rrTs&	
zRenderer.__init__T)r��leave_alternate_screenr6cCs�tddd�|_d|_d|_d|_t�|_d|_|r<|j�	�|j
rV|rV|j��d|_
|jrl|j�
�d|_|jr�|j��d|_|j��dS)Nrr@F)r�_cursor_pos�_last_screen�
_last_size�_last_styler�mouse_handlers�_min_available_heightr*Zscroll_buffer_to_promptr�Zquit_alternate_screenr��disable_mouse_supportr�Zdisable_bracketed_paste�flush)rqr�r�r8r8r:r�xs$




zRenderer.resetr7cCs|jS)zn
        The `Screen` class that was generated during the last rendering.
        This can be `None`.
        )r��rqr8r8r:�last_rendered_screen�szRenderer.last_rendered_screencCs@|js|jdkrdSz|j��|_WdSty:YdS0dS)z�
        True when the height from the cursor until the bottom of the terminal
        is known. (It's often nicer to draw bottom toolbars only if the height
        is known, in order to avoid flickering when the CPR response arrives.)
        rTFN)r1r�r*�get_rows_below_cursor_position�NotImplementedErrorr�r8r8r:�height_is_known�szRenderer.height_is_knowncCsN|jr
dS|jdkrB|j��j}|jr.|jjnd}|t|j|�Std��dS)zU
        Return the number of rows visible in the terminal above the layout.
        rzRows above layout is unknown.N)	r�r�r*�get_sizerYr�rarVrh)rq�
total_rowsZlast_screen_heightr8r8r:�rows_above_layout�s
zRenderer.rows_above_layoutcs��jjdksJ��jr(�j��j�_dSz�j���_WdStyLYn0�j	t
jkr^dSdd��fdd�}�j	t
jkr�|�dS�j
r�dS|�dd��fdd�}t��|��dS)aS
        Get current cursor position.

        We do this to calculate the minimum available height that we can
        consume for rendering the prompt. This is the available space below te
        cursor.

        For vt100: Do CPR request. (answer will arrive later.)
        For win32: Do API call. (Answer comes immediately.)
        rNr7cs�j�t���j��dSrp)r�rUrr*Zask_for_cprr8r�r8r:�do_cpr�sz9Renderer.request_absolute_cursor_position.<locals>.do_cprc�s6t�j�IdH�jtjkr2tj�_�jr2���dSrp)r�CPR_TIMEOUTr�rzr}r|r�r8r�r8r:�timer�s
z8Renderer.request_absolute_cursor_position.<locals>.timer)r�rBr1r*r�rYr�r�r�r�rzr|r{�waiting_for_cprrZcreate_background_task)rqr�r�r8r�r:� request_absolute_cursor_position�s(
z)Renderer.request_absolute_cursor_positionrMcCsVtj|_|j��j}||d}||_z|j��}Wnt	yFYn0|�
d�dS)z�
        To be called when we know the absolute cursor position.
        (As an answer of a "Cursor Position Request" response.)
        r>N)rzr{r�r*r�rYr�r��popleft�
IndexErrorZ
set_result)rqrNr�Zrows_below_cursor�fr8r8r:�report_absolute_cursor_rowsz#Renderer.report_absolute_cursor_rowcCs
t|j�S)zi
        Waiting for CPR flag. True when we send the request, but didn't got a
        response.
        )rxr�r�r8r8r:r�szRenderer.waiting_for_cprr>)�timeoutr6c�s�t�j���r�jtjkrdSdd��fdd�}dd����fdd�}t|��t|��h}t|td�IdH\}}|D]}|��qtdS)z*
        Wait for a CPR response.
        Nr7c�s�D]}|IdHqdSrpr8�Z
response_f)�cpr_futuresr8r:�wait_for_responses1sz;Renderer.wait_for_cpr_responses.<locals>.wait_for_responsesc�s,t��IdH�D]}|��qt��_dSrp)r�cancelrr�r��r�rqr�r8r:�wait_for_timeout5s
z9Renderer.wait_for_cpr_responses.<locals>.wait_for_timeout)Zreturn_when)	�listr�r�rzr|rrrr�)rqr�r�r�Ztasks�_ZpendingZtaskr8r�r:�wait_for_cpr_responses's
	�zRenderer.wait_for_cpr_responsesr&r#)r)rcr0r6cCsp|j}|jr |js d|_|��|js6|j��d|_|jsL|j��d|_|��}|rn|j	sn|�
�d|_	n|s�|j	r�|��d|_	|��}t
�}d|_t�}|jr�|j}	nJ|r�|j�|j|j�j}	n0|jr�|jjnd}
t|j|
|j�|j|j�j�}	t|	|j�}	|j|k�rd|_|j��|jk�sH|j��|jk�sH|j |j!k�rZd|_d|_"d|_#|j"du�rxt$|jj%|j�|_"|j#du�r�t&|j"�|_#|j��|_|j��|_|j |_!|jj'||t(dd|j|	d�dddd�|�)�|j*�r�|�+|j*�t,||||j-|j |j|j.||j|j"|j#||j�r*|jjndd�
\|_-|_.||_||_||_/|�0�|j1|j2_1|�rl|�3�dS)	z�
        Render the current interface to the output.

        :param is_done: When True, put the cursor at the end of the interface. We
                won't print any changes to this part.
        TFrN)ZxposZyposrFra�)Zparent_styleZerase_bgZz_index)r1r2r3r4r5)4r*r1r�Zenter_alternate_screenr�Zenable_bracketed_paster�Zreset_cursor_key_moderr�Zenable_mouse_supportr�r�rrerrYZ	containerZpreferred_heightrXZ	preferredr�rarVr�r`r�rJZinvalidation_hashr�ror�r-r�r�r�r'rnr(Zwrite_to_screenrZdraw_all_floatsZ
exit_styleZappend_style_to_contentrgr�r�r�r�Zvisible_windowsrcr�)rqr)rcr0r*Zneeds_mouse_supportr4r+r�raZlast_heightr8r8r:�renderEs�	



�����
�
����
zRenderer.render)r�r6cCsR|j}|�|jj�|�|jj�|��|��|��|�	�|j
|d�dS)aR
        Hide all output and put the cursor back at the first line. This is for
        instance used for running a system command (while hiding the CLI) and
        later resuming the same CLI.)

        :param leave_alternate_screen: When True, and when inside an alternate
            screen buffer, quit the alternate screen.
        )r�N)r*r]r�rAr\rBr_r;rdr�r�)rqr�r*r8r8r:�erase�s	zRenderer.erasecCs6|��|j}|��|�dd�|��|��dS)z,
        Clear screen and go to 0,0
        rN)r�r*Zerase_screenZcursor_gotor�r�)rqr*r8r8r:�clear�szRenderer.clear)FFN)FT)r>)F)T)rirjrkrlr�rrrxrrrrrr��propertyrr�r�r^r�r�r�r�r�r�r�r�r8r8r8r:r$GsB
��$.
=��N)r*�formatted_textrJror-r6cCs�t|�}|pt�}|p|��}|��|��d}t|j|�}|D]V^}}	}
||}||krv|rn|�||�n|��|}|	�dd�}	|�	|	�dd��qB|��|�
�dS)zT
    Print a list of (style_str, text) tuples in the given style to the output.
    Nr?r��
r=)rr Zget_default_color_depthr;rdr'rnr[�replacerGr�)r*r�rJror-Z	fragmentsZ
last_attrsr2rt�textr�rur8r8r:r%�s(

�)NN)=rlZasynciorrrrr�collectionsr�enumr�typingr	r
rrr
rrrZ"prompt_toolkit.application.currentrZprompt_toolkit.data_structuresrrZprompt_toolkit.filtersrrZprompt_toolkit.formatted_textrrZ$prompt_toolkit.layout.mouse_handlersrZprompt_toolkit.layout.screenrrrZprompt_toolkit.outputrrZprompt_toolkit.stylesrrr r!Zprompt_toolkit.applicationr"Zprompt_toolkit.layout.layoutr#�__all__rmrxr^rg�	Exceptionrhr'r(rzr$r%r8r8r8r:�<module>sh(��f0��

Youez - 2016 - github.com/yon3zu
LinuXploit