Yohohohohohooho | Sanrei Aya
Sanrei Aya


Server : LiteSpeed
System : Linux barito.iixcp.rumahweb.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : elvh3918 ( 1528)
PHP Version : 8.2.31
Disable Function : mail
Directory :  /usr/local/lib/python3.9/site-packages/prompt_toolkit/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

��Sh�r�@s�dZddlmZddlmZmZmZmZmZddl	m
Z
ddlmZddl
mZmZmZmZmZddlmZddlmZdd	lmZmZdd
lmZmZddlmZmZddl m!Z!dd
l"m#Z#m$Z$m%Z%ddl&m'Z'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-e�rddl.m/Z/ddl0m1Z1ddgZ2dddddddddddddd d!�d"d#�Z3Gd$d%�d%e4�Z5Gd&d�dee6e*f�Z7Gd'd�dee6e8f�Z9Gd(d)�d)e�Z:Gd*d�d�Z;d3dd,d-d.d/d0d1�d2d�Z<d+S)4z_
Renders the command line on the console.
(Redraws parts of the input line that were changed.)
�)�annotations)�FIRST_COMPLETED�Future�
ensure_future�sleep�wait)�deque)�Enum)�
TYPE_CHECKING�Any�Callable�Dict�Hashable)�get_app)�CursorShape)�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]rrrr�
Screen | Nonez
str | None�bool�_StyleStringToAttrsCache�_StyleStringHasStyleCacher�intztuple[Point, str | None])�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��	ddd������	��fdd�}d	dd
������fdd�}d
dd��
fdd�}|s��	�|r�|s�|�
�|s�|r�|�kr�|tddd����	�|��t
�}t|j|
�}tt|j|j�|
�}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}�qf|�r||k�r|t|d|d����	�|���q||jk�rL|td|dd���|�rl|td|d���|��n||�|jj���|�s�|�s�|���	�|j�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.
    �None�r8cs��d�dS)z'Wrapper around Output.reset_attributes.N�r;)�_output_reset_attributesr1r;�A/usr/local/lib/python3.9/site-packages/prompt_toolkit/renderer.py�reset_attributesZsz-_output_screen_diff.<locals>.reset_attributesr)�newr8cs��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�writer;r=�move_cursor`s"



z(_output_screen_diff.<locals>.move_cursorr)�charr8csN�|jkr�|j�n4�|j}�r0|��kr:�|���|j�|j�dS)z5
        Write the output of this character.
        N)�stylerL)rL�	new_attrs)�_output_set_attributesr4r/r1rJr;r=�output_char{s



z(_output_screen_diff.<locals>.output_charzdict[int, Char]r*��rowr8cs"�fdd�|��D�}t|dd�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).
        c3s*|]"\}}|jdks�|jr|VqdS)� N)rLrM)�.0�index�cell�r5r;r=�	<genexpr>�s�zD_output_screen_diff.<locals>.get_max_column_index.<locals>.<genexpr>r)�default)�items�max)rRZnumbersrWr;r=�get_max_column_index�s
�z1_output_screen_diff.<locals>.get_max_column_indexrrCrA)�columns�rowsrJ�	write_raw�set_attributesr>Zcursor_forward�	cursor_up�cursor_backward�hide_cursorZdisable_autowrapr�
erase_downr�min�heightr[�rangeZdata_bufferZzero_width_escapesrIrLrMrDrEZerase_end_of_lineZget_cursor_position�layoutZcurrent_window�enable_autowrap�show_cursor)r+r,r-r.r/r0r1r2r3r4r5r6r7rfr_rKrPr\Zcurrent_heightZ	row_countrEZnew_rowZprevious_rowZzero_width_escapes_rowZnew_max_line_lenZprevious_max_line_len�cZnew_charZold_charZ
char_widthr;)
rFrGrHr<rOr4r/r.r1r>r5rIrJr=�_output_screen_diff's~" ���





rlc@seZdZdZdS)�HeightIsUnknownErrorz>Information unavailable. Did not yet receive the CPR response.N)�__name__�
__module__�__qualname__�__doc__r;r;r;r=rm
srmc@s2eZdZdZdddd�dd�Zdd	d
�dd�Zd
S)r(zk
    A cache structure that maps style strings to :class:`.Attr`.
    (This is an important speed up.)
    zCallable[[str], Attrs]r r9)�get_attrs_for_style_str�style_transformationr8cCs||_||_dS�N)rrrs)�selfrrrsr;r;r=�__init__sz!_StyleStringToAttrsCache.__init__�strr��	style_strr8cCs"|�|�}|j�|�}|||<|Srt)rrrsZtransform_attrs)rury�attrsr;r;r=�__missing__s
z$_StyleStringToAttrsCache.__missing__N�rnrorprqrvr{r;r;r;r=r(sc@s0eZdZdZddd�dd�Zddd	�d
d�ZdS)
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.
    zdict[str, Attrs]r9)�style_string_to_attrsr8cCs
||_dSrt)r})rur}r;r;r=rv/sz"_StyleStringHasStyleCache.__init__rwr'rxcCs>|j|}t|jp.|jp.|jp.|jp.|jp.|j�}|||<|Srt)r}r'�colorZbgcolor�	underline�strike�blink�reverse)ruryrzZ
is_defaultr;r;r=r{2s
�����	z%_StyleStringHasStyleCache.__missing__Nr|r;r;r;r=r)$s
c@seZdZdZdZdZdZdS)�CPR_Supportz&Enum: whether or not CPR is supported.�	SUPPORTED�
NOT_SUPPORTED�UNKNOWNN)rnrorprqr�r�r�r;r;r;r=r�Asr�c@s�eZdZdZdZd0ddddd	d
d�dd
�Zd1ddd
d�dd�Zedd�dd��Zedd�dd��Z	edd�dd��Z
d
d�dd�Zdd
d�dd�Zedd�d d!��Z
d2dd
d#�d$d%�Zd3d&d'dd
d(�d)d*�Zd4dd
d+�d,d-�Zd
d�d.d/�ZdS)5r#z�
    Typical usage:

    ::

        output = Vt100_Output.from_pty(sys.stdout)
        r = Renderer(style, output)
        r.render(app, layout=...)
    �FNrrr'rzCallable[[], None] | Noner9)rMr,r3�
mouse_support�cpr_not_supported_callbackr8cCs�||_||_||_t|�|_||_d|_d|_d|_d|_	t
�|_tj
|_|jsXtj|_d|_d|_d|_d|_d|_|jdd�dS)NFT)�_scroll)rMr,r3rr�r��_in_alternate_screen�_mouse_support_enabled�_bracketed_paste_enabled�_cursor_key_mode_resetr�_waiting_for_cpr_futuresr�r��cpr_supportZresponds_to_cprr��_attrs_for_style�_style_string_has_style�_last_style_hash�_last_transformation_hash�_last_color_depth�reset)rurMr,r3r�r�r;r;r=rvVs&
zRenderer.__init__T)r��leave_alternate_screenr8cCs�tddd�|_d|_d|_d|_d|_t�|_d|_|rB|j	�
�|jr\|r\|j	��d|_|j
rr|j	��d|_
|jr�|j	��d|_|j	��|j	��|j	��dS)NrrCF)r�_cursor_pos�_last_screen�
_last_size�_last_style�_last_cursor_shaper�mouse_handlers�_min_available_heightr,Zscroll_buffer_to_promptr�Zquit_alternate_screenr��disable_mouse_supportr�Zdisable_bracketed_pasteZreset_cursor_shaperj�flush)rur�r�r;r;r=r�~s*






zRenderer.resetr&r:cCs|jS)zn
        The `Screen` class that was generated during the last rendering.
        This can be `None`.
        )r��rur;r;r=�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)r3r�r,�get_rows_below_cursor_position�NotImplementedErrorr�r;r;r=�height_is_known�szRenderer.height_is_knownr*cCsN|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_sizer^r�rfr[rm)ru�
total_rowsZlast_screen_heightr;r;r=�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.)
        rNr9r:cs�j�t���j��dSrt)r��appendrr,Zask_for_cprr;r�r;r=�do_cpr�sz9Renderer.request_absolute_cursor_position.<locals>.do_cprc�s6t�j�IdH�jtjkr2tj�_�jr2���dSrt)r�CPR_TIMEOUTr�r�r�r�r�r;r�r;r=�timers
z8Renderer.request_absolute_cursor_position.<locals>.timer)r�rEr3r,r�r^r�r�r�r�r�r�r��waiting_for_cprrZcreate_background_task)rur�r�r;r�r=� request_absolute_cursor_position�s(
z)Renderer.request_absolute_cursor_positionrQcCsVtj|_|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.)
        rAN)r�r�r�r,r�r^r�r��popleft�
IndexError�
set_result)rurRr�Zrows_below_cursor�fr;r;r=�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.
        )r'r�r�r;r;r=r�(szRenderer.waiting_for_cprrA)�timeoutr8c�s�t�j���r�jtjkrdSdd��fdd�}dd����fdd�}t|��t|��h}t|td�IdH\}}|D]}|��qtdS)	z*
        Wait for a CPR response.
        Nr9r:c�s�D]}|IdHqdSrtr;�Z
response_f)�cpr_futuresr;r=�wait_for_responses:sz;Renderer.wait_for_cpr_responses.<locals>.wait_for_responsesc�s,t��IdH�D]}|��qt��_dSrt)r�cancelrr�r��r�rur�r;r=�wait_for_timeout>s
z9Renderer.wait_for_cpr_responses.<locals>.wait_for_timeout)�return_when)	�listr�r�r�r�rrrr�)rur�r�r��tasks�_�pending�taskr;r�r=�wait_for_cpr_responses0s
	�zRenderer.wait_for_cpr_responsesr%r")r+rhr2r8cCs�|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�
\|_-|_.||_||_||_/|j0�1|�}|j2du�sp|j2|k�r�|�3|�||_2|�4�|j5|j6_5|�r�|�7�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)ZxposZyposrIrf�)Zparent_styleZerase_bgZz_index)r3r4r5r6r7)8r,r3r�Zenter_alternate_screenr�Zenable_bracketed_paster�Zreset_cursor_key_moder�r�Zenable_mouse_supportr�r�rrjrr^�	containerZpreferred_heightr]�	preferredr�rfr[r�rer�rMZinvalidation_hashr�rsr�r/r�r�r�r(rrr)Zwrite_to_screenrZdraw_all_floatsZ
exit_styleZappend_style_to_contentrlr�r�r��cursorZget_cursor_shaper�Zset_cursor_shaper�Zvisible_windowsrhr�)rur+rhr2r,Zneeds_mouse_supportr6r-r�rfZlast_heightZnew_cursor_shaper;r;r=�renderNs�	



�����
�
������

zRenderer.render)r�r8cCsR|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,rbr�rDrarErdr>rir�r�)rur�r,r;r;r=�erase�s	zRenderer.erasecCs6|��|j}|��|�dd�|��|��dS)z,
        Clear screen and go to 0,0
        rN)r�r,�erase_screenZcursor_gotor�r�)rur,r;r;r=�clear�szRenderer.clear)FFN)FT)rA)F)T)rnrorprqr�rvr��propertyr�r�r�r�r�r�r�r�r�r�r;r;r;r=r#Is.
�(1
=�NrrzStyleTransformation | NonezColorDepth | Noner9)r,�formatted_textrMrsr/r8cCs�t|�}|pt�}|p|��}|��|��d}t|j|�}|D]n^}}	}
||}||krv|rn|�||�n|��|}d|vr�|�|	�qB|	�	dd�}	|	�	dd�}	|�
|	�qB|��|��dS)zT
    Print a list of (style_str, text) tuples in the given style to the output.
    Nz[ZeroWidthEscape]rBr��
r@)rrZget_default_color_depthr>rir(rrr`r_�replacerJr�)r,r�rMrsr/�	fragmentsZ
last_attrsr4ry�textr�rzr;r;r=r$s.

�)NN)=rq�
__future__r�asynciorrrrr�collectionsr�enumr	�typingr
rrr
rZ"prompt_toolkit.application.currentrZprompt_toolkit.cursor_shapesrZprompt_toolkit.data_structuresrrZprompt_toolkit.filtersrrZprompt_toolkit.formatted_textrrZ$prompt_toolkit.layout.mouse_handlersrZprompt_toolkit.layout.screenrrrZprompt_toolkit.outputrrZprompt_toolkit.stylesrrrr Zprompt_toolkit.applicationr!Zprompt_toolkit.layout.layoutr"�__all__rl�	Exceptionrmrwr(r'r)r�r#r$r;r;r;r=�<module>sB�(dB�

Yohohohohohooho | Sanrei Aya