ó
    NÎhÖr  ã                  ó  • S r SSKJr  SSKJrJrJrJrJr  SSK	J
r
  SSKJr  SSKJrJrJrJrJr  SSKJr  SSKJr  SS	KJrJr  SS
KJrJr  SSKJrJr  SSK J!r!  SSK"J#r#J$r$J%r%  SSK&J'r'J(r(  SSK)J*r*J+r+J,r,J-r-  \(       a  SSK.J/r/  SSK0J1r1  SS/r2                            S S jr3 " S S\45      r5 " S S\\6\*4   5      r7 " S S\\6\84   5      r9 " S S\5      r: " S S5      r;  S!           S"S jjr<g)#z_
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Ú_StyleStringToAttrsCacheÚ_StyleStringHasStyleCachec                ó  ^^^^	^
^^^ ^!^"^#^$^%• UR                   UR                  sm$nUR                  m%UR                  nUR                  m"UR
                  m!UR                  mUR                  m UR                  mUR                  5         SU!U4S jjm#S	UUU UU#U$U%4S jjnS
U"U	UUU%4S jjnSU
4S jjnU(       d  T#" 5         U(       a  U(       d  UR                  5         U(       d  U(       a  UT$:w  a1  U" [        SSS95      mT#" 5         UR                  5         [        5       n[        UR                  U5      n[        [!        UR                  UR                  5      U5      n[#        U5       GHJ  nUR$                  U   nUR$                  U   nUR&                  U   n[        T$S-
  U" U5      5      n[        T$S-
  U" U5      5      nSnUU::  aª  UU   nUU   nUR(                  =(       d    SnUR*                  UR*                  :w  d  UR,                  UR,                  :w  aJ  U" [        UUS95      mUU;   a  U" UU   5        U" U5        [        TR.                  U-   TR0                  S9mUU-  nUU::  a  Mª  U(       d  GM  UU:  d  GM   U" [        US-   US95      mT#" 5         UR3                  5         GMM     UUR                  :”  a  U" [        SUS-
  S95      mU(       a!  U" [        SUS95      mUR                  5         O+U" UR5                  U R6                  R8                  5      5      mU(       d  U(       d  UR;                  5         T#" 5         UR<                  (       a  UR=                  5         TT4$ )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.
c                 ó   >• T " 5         Smg)z'Wrapper around Output.reset_attributes.N© )Ú_output_reset_attributesÚ
last_styles   €€ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/prompt_toolkit/renderer.pyÚreset_attributesÚ-_output_screen_diff.<locals>.reset_attributesZ   s   ø€ ñ 	!Ô"Ø‰
ó    c                óú  >• TR                   TR                  p!U R                  U:”  a5  T" 5         T	" SU R                  U-
  -  5        SnT" U R                   5        U $ U R                  U:  a  T" X R                  -
  5        UTS-
  :¼  a  T	" S5        T" U R                   5        U $ U R                   U:  d	  UTS-
  :¼  a  T" XR                   -
  5        U $ U R                   U:”  a  T" U R                   U-
  5        U $ )z9Move cursor to this `new` point. Returns the given Point.ú
r   é   Ú©ÚxÚy)
ÚnewÚ	current_xÚ	current_yÚ_output_cursor_backwardÚ_output_cursor_forwardÚ_output_cursor_upÚcurrent_posr.   ÚwidthÚwrites
      €€€€€€€r-   Úmove_cursorÚ(_output_screen_diff.<locals>.move_cursor`   sæ   ø€ à*Ÿ}™}¨k¯m©m�9à�5‰5�9Óñ
 ÔÙ�&˜CŸE™E IÑ-Ñ.Ô/ØˆIÙ" 3§5¡5Ô)ØˆJØ�U‰U�YÓÙ˜i¯%©%Ñ/Ô0à˜ ™	Ó!Ù�$ŒKÙ" 3§5¡5Ô)ð ˆ
ð �U‰U�YÓ )¨u°q©yÓ"8Ù# I·±Ñ$5Ô6ð ˆ
ð �U‰U�YÓÙ" 3§5¡5¨9Ñ#4Ô5àˆ
r0   c                óØ   >• TU R                   :X  a  T" U R                  5        gTU R                      nT(       a	  UTT   :w  a	  T" UT5        T" U R                  5        U R                   mg)z%
Write the output of this character.
N)ÚstyleÚchar)rE   Ú	new_attrsÚ_output_set_attributesÚattrs_for_style_stringÚcolor_depthr,   r@   s     €€€€€r-   Úoutput_charÚ(_output_screen_diff.<locals>.output_char{   s\   ø€ ð ˜Ÿ™Ó#Ù�$—)‘)Õð /¨t¯z©zÑ:ˆIÞ Ð.DÀZÑ.PÓ!PÙ& y°+Ô>á�$—)‘)ÔØŸ™‰Jr0   c                óL   >• U4S jU R                  5        5       n[        USS9$ )aæ  
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).
c              3  óx   >#   • U  H/  u  pUR                   S :w  d  TUR                     (       d  M+  Uv •  M1     g7f)Ú N)rE   rD   )Ú.0ÚindexÚcellÚstyle_string_has_styles      €r-   Ú	<genexpr>ÚD_output_screen_diff.<locals>.get_max_column_index.<locals>.<genexpr>ž   s4   øé € ð 
â*‘�Ø�y‰y˜CÓÐ#9¸$¿*¹*Õ#E÷ ‰EÚ*ùs   ƒ*:±	:r   )Údefault)ÚitemsÚmax)ÚrowÚnumbersrR   s     €r-   Úget_max_column_indexÚ1_output_screen_diff.<locals>.get_max_column_index‘   s'   ø€ ô
à"Ÿy™yœ{ó
ˆô
 �7 AÑ&Ð&r0   r   r5   r3   ©ÚreturnÚNone)r8   r   r]   r   )rE   r   r]   r^   )rX   zdict[int, Char]r]   Úint)ÚcolumnsÚrowsr@   Ú	write_rawÚset_attributesr.   Úcursor_forwardÚ	cursor_upÚcursor_backwardÚhide_cursorÚdisable_autowrapr   Ú
erase_downr   ÚminÚheightrW   ÚrangeÚdata_bufferÚzero_width_escapesr?   rE   rD   r6   r7   Úerase_end_of_lineÚget_cursor_positionÚlayoutÚcurrent_windowÚenable_autowrapÚshow_cursor)&ÚappÚoutputÚscreenr>   rI   Úprevious_screenr,   Úis_doneÚfull_screenrH   rR   ÚsizeÚprevious_widthrk   rb   rA   rJ   rZ   Úcurrent_heightÚ	row_countr7   Únew_rowÚprevious_rowÚzero_width_escapes_rowÚnew_max_line_lenÚprevious_max_line_lenÚcÚnew_charÚold_charÚ
char_widthr;   r<   r=   r+   rG   r.   r?   r@   s&      `` `  ``                   @@@@@@@@r-   Ú_output_screen_diffrˆ   '   s  ÿü€ ðD —L‘L $§)¡)€M€Eˆ6ð �L‰L€EØ× Ñ €Ið $×2Ñ2ÐØ%×6Ñ6ÐØ#×2Ñ2ÐØ×(Ñ(ÐØ$×4Ñ4Ðð ×ÑÔ÷ð ÷õ ÷6$ó $÷,'ö* ÙÔö ¦+Ø×ÑÔ!ö
 	–¨.¸EÓ*Aá!¤%¨!¨q¡/Ó2ˆÙÔØ×ÑÔä ›(ˆô
 ˜Ÿ™¨Ó/€Nô ”C˜Ÿ™ ×'=Ñ'=Ó>ÀÓG€Iä�9×ˆØ×$Ñ$ QÑ'ˆØ&×2Ñ2°1Ñ5ˆØ!'×!:Ñ!:¸1Ñ!=Ðä˜u q™yÑ*>¸wÓ*GÓHÐÜ # E¨A¡IÑ/CÀLÓ/QÓ RÐð ˆØÐ#Ó#Ø˜q‘zˆHØ# A‘ˆHØ!Ÿ™×,¨1ˆJð
 �}‰} §¡Ó-°·±À8Ç>Á>Ó1QÙ)¬%°!°q©/Ó:�ð Ð.Ó.ÙÐ4°QÑ7Ô8á˜HÔ%Ü# k§m¡m°jÑ&@ÀKÇMÁMÑR�à�‰OˆAð% Ð#Õ#÷* ‰?Ð/Ð2GÖGÙ%¤eÐ.>ÀÑ.BÀaÑ&HÓIˆKÙÔØ×$Ñ$×&ñE ð\ ˜×.Ñ.Ó.Ù!¤%¨!¨~ÀÑ/AÑ"BÓCˆö Ù!¤%¨!¨~Ñ">Ó?ˆØ×ÑÕá! &×"<Ñ"<¸S¿Z¹Z×=VÑ=VÓ"WÓXˆæ–kØ×ÑÔ ñ Ôà××Ø×ÑÔà˜
Ð"Ð"r0   c                  ó   • \ rS rSrSrSrg)ÚHeightIsUnknownErrori
  z>Information unavailable. Did not yet receive the CPR response.r*   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r*   r0   r-   rŠ   rŠ   
  s   † ÜDr0   rŠ   c                  ó8   • \ rS rSrSr      SS jrSS jrSrg)	r&   i  z_
A cache structure that maps style strings to :class:`.Attr`.
(This is an important speed up.)
c                ó   • Xl         X l        g ©N©Úget_attrs_for_style_strÚstyle_transformation)Úselfr•   r–   s      r-   Ú__init__Ú!_StyleStringToAttrsCache.__init__  s   € ð
 (?Ô$Ø$8Õ!r0   c                óf   • U R                  U5      nU R                  R                  U5      nX U'   U$ r“   )r•   r–   Útransform_attrs)r—   Ú	style_strÚattrss      r-   Ú__missing__Ú$_StyleStringToAttrsCache.__missing__  s4   € Ø×,Ñ,¨YÓ7ˆØ×)Ñ)×9Ñ9¸%Ó@ˆàˆY‰Øˆr0   r”   N)r•   zCallable[[str], Attrs]r–   r!   r]   r^   )rœ   Ústrr]   r   ©r‹   rŒ   r�   rŽ   r�   r˜   rž   r�   r*   r0   r-   r&   r&     s-   † ñð
9à!7ð9ð 2ð9ð 
ô	9÷r0   c                  ó,   • \ rS rSrSrSS jrSS jrSrg)	r'   i$  ac  
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.
c                ó   • Xl         g r“   ©Ústyle_string_to_attrs)r—   r¥   s     r-   r˜   Ú"_StyleStringHasStyleCache.__init__/  s   € Ø%:Õ"r0   c                ó  • U R                   U   n[        UR                  =(       dX    UR                  =(       dE    UR                  =(       d2    UR
                  =(       d    UR                  =(       d    UR                  5      nX0U'   U$ r“   )r¥   ÚboolÚcolorÚbgcolorÚ	underlineÚstrikeÚblinkÚreverse)r—   rœ   r�   Ú
is_defaults       r-   rž   Ú%_StyleStringHasStyleCache.__missing__2  st   € Ø×*Ñ*¨9Ñ5ˆÜØ�K‰K÷ Ø�}‰}÷à�‰÷ð �|‰|÷ð �{‰{÷	ð
 �}‰}ó
ˆ
ð %ˆY‰ØÐr0   r¤   N)r¥   zdict[str, Attrs]r]   r^   )rœ   r    r]   r¨   r¡   r*   r0   r-   r'   r'   $  s   † ñô;÷r0   c                  ó$   • \ rS rSrSrSrSrSrSrg)ÚCPR_SupportiA  z&Enum: whether or not CPR is supported.Ú	SUPPORTEDÚNOT_SUPPORTEDÚUNKNOWNr*   N)	r‹   rŒ   r�   rŽ   r�   r³   r´   rµ   r�   r*   r0   r-   r²   r²   A  s   † Ù,à€IØ#€MØƒGr0   r²   c                  óü   • \ rS rSrSrSr   S           SS jjrSSS jjr\SS j5       r	\SS j5       r
\SS	 j5       rSS
 jrSS jr\SS j5       rSSS jjr S       SS jjrSS S jjrSS jrSrg)!r$   iI  z‚
Typical usage:

::

    output = Vt100_Output.from_pty(sys.stdout)
    r = Renderer(style, output)
    r.render(app, layout=...)
é   Nc                ó„  • Xl         X l        X0l        [        U5      U l        XPl        SU l        SU l        SU l        SU l	        [        5       U l        [        R                  U l        UR                  (       d  [        R                   U l        S U l        S U l        S U l        S U l        S U l        U R-                  SS9  g )NFT)Ú_scroll)rD   rv   rz   r   Úmouse_supportÚcpr_not_supported_callbackÚ_in_alternate_screenÚ_mouse_support_enabledÚ_bracketed_paste_enabledÚ_cursor_key_mode_resetr	   Ú_waiting_for_cpr_futuresr²   rµ   Úcpr_supportÚresponds_to_cprr´   Ú_attrs_for_styleÚ_style_string_has_styleÚ_last_style_hashÚ_last_transformation_hashÚ_last_color_depthÚreset)r—   rD   rv   rz   rº   r»   s         r-   r˜   ÚRenderer.__init__V  sµ   € ð Œ
ØŒØ&ÔÜ& }Ó5ˆÔØ*DÔ'ð %*ˆÔ!Ø&+ˆÔ#Ø(-ˆÔ%Ø&+ˆÔ#ô >C»WˆÔ%Ü&×.Ñ.ˆÔà×%×%Ü*×8Ñ8ˆDÔð BFˆÔØIMˆÔ$Ø15ˆÔØ:>ˆÔ&Ø48ˆÔà�
‰
˜4ˆ
Ò r0   c                óž  • [        SSS9U l        S U l        S U l        S U l        S U l        [        5       U l        SU l        U(       a  U R                  R                  5         U R                  (       a(  U(       a!  U R                  R                  5         SU l        U R                  (       a!  U R                  R                  5         SU l        U R                  (       a!  U R                  R!                  5         SU l        U R                  R#                  5         U R                  R%                  5         U R                  R'                  5         g )Nr   r5   F)r   Ú_cursor_posÚ_last_screenÚ
_last_sizeÚ_last_styleÚ_last_cursor_shaper   Úmouse_handlersÚ_min_available_heightrv   Úscroll_buffer_to_promptr¼   Úquit_alternate_screenr½   Údisable_mouse_supportr¾   Údisable_bracketed_pasteÚreset_cursor_shapert   Úflush)r—   r¹   Úleave_alternate_screens      r-   rÈ   ÚRenderer.reset~  sú   € ä  1¨™?ˆÔð ,0ˆÔØ'+ˆŒØ'+ˆÔØ6:ˆÔô ,›oˆÔð &'ˆÔ"ö
 Ø�K‰K×/Ñ/Ô1ð ×$×$Ö)?Ø�K‰K×-Ñ-Ô/Ø(-ˆDÔ%ð ×&×&Ø�K‰K×-Ñ-Ô/Ø*/ˆDÔ'ð ×(×(Ø�K‰K×/Ñ/Ô1Ø,1ˆDÔ)à�‰×&Ñ&Ô(Ø�‰×ÑÔ!ð
 	�‰×ÑÕr0   c                ó   • U R                   $ )zV
The `Screen` class that was generated during the last rendering.
This can be `None`.
)rÌ   ©r—   s    r-   Úlast_rendered_screenÚRenderer.last_rendered_screen¯  s   € ð × Ñ Ð r0   c                ó¨   • U R                   (       d  U R                  S:”  a  g U R                  R                  5       U l        g! [         a     gf = f)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.)
r   TF)rz   rÑ   rv   Úget_rows_below_cursor_positionÚNotImplementedErrorrÛ   s    r-   Úheight_is_knownÚRenderer.height_is_known·  sL   € ð ××˜t×9Ñ9¸AÓ=Øð	Ø)-¯©×)SÑ)SÓ)UˆDÔ&ØøÜ"ó 	Ùð	ús   ¤A Á
AÁAc                ó(  • U R                   (       a  gU R                  S:”  af  U R                  R                  5       R                  nU R
                  (       a  U R
                  R                  OSnU[        U R                  U5      -
  $ [        S5      e)zE
Return the number of rows visible in the terminal above the layout.
r   zRows above layout is unknown.)	r¼   rÑ   rv   Úget_sizera   rÌ   rk   rW   rŠ   )r—   Ú
total_rowsÚlast_screen_heights      r-   Úrows_above_layoutÚRenderer.rows_above_layoutÆ  sx   € ð
 ×$×$ØØ×'Ñ'¨!Ó+ØŸ™×-Ñ-Ó/×4Ñ4ˆJØ=A×=N×=N ×!2Ñ!2×!9Ò!9ÐTUÐØ¤ D×$>Ñ$>Ð@RÓ SÑSÐSä&Ð'FÓGÐGr0   c                ó.  ^ • T R                   R                  S:X  d   eT R                  (       a*  T R                  R	                  5       R
                  T l        g T R                  R                  5       T l        g! [         a     Of = fT R                  [        R                  :X  a  gSU 4S jjnT R                  [        R                  :X  a  U" 5         gT R                  (       a  gU" 5         SU 4S jjn[        5       R                  U" 5       5        g)a  
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.)
r   Nc                 ó€   >• T R                   R                  [        5       5        T R                  R	                  5         g r“   )rÀ   Úappendr   rv   Úask_for_cprrÛ   s   €r-   Údo_cprÚ9Renderer.request_absolute_cursor_position.<locals>.do_cprô  s)   ø€ à×)Ñ)×0Ñ0´³Ô:Ø�K‰K×#Ñ#Õ%r0   c               “  óø   >#   • [        T R                  5      I S h  v•N   T R                  [        R                  :X  a8  [        R
                  T l        T R                  (       a  T R                  5         g g g  N[7fr“   )r   ÚCPR_TIMEOUTrÁ   r²   rµ   r´   r»   rÛ   s   €r-   ÚtimerÚ8Renderer.request_absolute_cursor_position.<locals>.timer  sb   øé € Ü˜×(Ñ(Ó)×)Ð)ð ×Ñ¤;×#6Ñ#6Ó6Ü#.×#<Ñ#<�Ô à×2×2à×3Ñ3Õ5ð 3ð 7ñ *ùs   ƒA:œA8�AA:r\   )rË   r7   rz   rv   rä   ra   rÑ   rß   rà   rÁ   r²   r´   r³   Úwaiting_for_cprr   Úcreate_background_task)r—   rí   rñ   s   `  r-   Ú request_absolute_cursor_positionÚ)Renderer.request_absolute_cursor_positionÔ  sß   ø€ ð ×Ñ×!Ñ! QÓ&Ð&Ð&ð ××Ø)-¯©×)=Ñ)=Ó)?×)DÑ)DˆDÔ&Øð	Ø)-¯©×)SÑ)SÓ)UˆDÔ&ØøÜ"ó 	Ùð	úð ×Ñœ{×8Ñ8Ó8Ø÷	&ð
 ×Ñœ{×4Ñ4Ó4ÙŒHØð ××ØáŒ÷		6ô 	‹	×(Ñ(©«Õ1s   ÁA: Á:
BÂBc                ó  • [         R                  U l        U R                  R	                  5       R
                  nX!-
  S-   nX0l         U R                  R                  5       nUR                  S5        g! [         a     gf = f)zq
To be called when we know the absolute cursor position.
(As an answer of a "Cursor Position Request" response.)
r3   N)r²   r³   rÁ   rv   rä   ra   rÑ   rÀ   ÚpopleftÚ
set_resultÚ
IndexError)r—   rX   rå   Úrows_below_cursorÚfs        r-   Úreport_absolute_cursor_rowÚ#Renderer.report_absolute_cursor_row  s}   € ô
 '×0Ñ0ˆÔð —[‘[×)Ñ)Ó+×0Ñ0ˆ
Ø&Ñ,¨qÑ0Ðð &7Ô"ð	Ø×-Ñ-×5Ñ5Ó7ˆAð �L‰L˜Õøô ó 	Ùð	ús   ÁA4 Á4
BÂ Bc                ó,   • [        U R                  5      $ )zQ
Waiting for CPR flag. True when we send the request, but didn't got a
response.
)r¨   rÀ   rÛ   s    r-   ró   ÚRenderer.waiting_for_cpr(  s   € ô �D×1Ñ1Ó2Ð2r0   c              ƒ  óR  ^ ^^#   • [        T R                  5      mT(       a  T R                  [        R                  :X  a  gSU4S jjnSUU U4S jjn[        U" 5       5      [        U" 5       5      1n[        U[        S9I Sh  v•N u  pVU H  nUR                  5         M     g N 7f)z
Wait for a CPR response.
Nc               “  ó8   >#   • T H  n U I S h  v•N   M     g  N	7fr“   r*   )Ú
response_fÚcpr_futuress    €r-   Úwait_for_responsesÚ;Renderer.wait_for_cpr_responses.<locals>.wait_for_responses:  s   øé € Û)�
Ø × Ò ò *Ù ùs   ƒŽ�
c               “  óˆ   >#   • [        T5      I S h  v•N   T H  n U R                  5         M     [        5       Tl        g  N-7fr“   )r   Úcancelr	   rÀ   )r  r  r—   Útimeouts    €€€r-   Úwait_for_timeoutÚ9Renderer.wait_for_cpr_responses.<locals>.wait_for_timeout>  s:   øé € Ü˜“.× Ð ó *�
Ø×!Ñ!Ö#ñ *ä,1«GˆDÕ)ñ !ùs   ƒA’A “.A)Úreturn_whenr\   )	ÚlistrÀ   rÁ   r²   r´   r   r   r   r  )	r—   r	  r  r
  ÚtasksÚ_ÚpendingÚtaskr  s	   ``      @r-   Úwait_for_cpr_responsesÚRenderer.wait_for_cpr_responses0  s�   úé € ô ˜4×8Ñ8Ó9ˆö ˜d×.Ñ.´+×2KÑ2KÓKØ÷	!÷	4ñ 	4ô Ñ,Ó.Ó/ÜÑ*Ó,Ó-ð
ˆô   ´?ÑC×C‰
ˆÛˆDØ�K‰KŽMò ñ Dùs   …A?B'ÂB%Â!B'c                ó6
  • U R                   nU R                  (       a(  U R                  (       d  SU l        UR                  5         U R                  (       d!  U R                   R                  5         SU l        U R                  (       d!  U R                   R                  5         SU l        U R                  5       nU(       a)  U R                  (       d  UR                  5         SU l	        O/U(       d(  U R                  (       a  UR                  5         SU l	        UR                  5       n[        5       nSUl        [        5       nU R                  (       a  UR                   n	OºU(       a;  UR"                  R%                  UR&                  UR                   5      R(                  n	OxU R*                  (       a  U R*                  R,                  OSn
[/        U R0                  U
UR"                  R%                  UR&                  UR                   5      R(                  5      n	[3        X–R                   5      n	U R4                  U:w  a  SU l        U R6                  R9                  5       U R:                  :w  dB  UR<                  R9                  5       U R>                  :w  d  UR@                  U RB                  :w  a  SU l        SU l"        SU l#        U RD                  c/  [I        U R6                  RJ                  UR<                  5      U l"        U RF                  c  [M        U RD                  5      U l#        U R6                  R9                  5       U l        UR<                  R9                  5       U l        UR@                  U l!        UR"                  RO                  UU[Q        SSUR&                  U	S9SSSS9  URS                  5         URT                  (       a  URW                  URT                  5        [Y        UUUU RZ                  UR@                  U R*                  U R\                  UU R                  U RD                  U RF                  UU R4                  (       a  U R4                  R&                  OSS9u  U l-        U l.        Xpl        X`l        X€l/        UR`                  Rc                  U5      nU Rd                  b  U Rd                  U:w  a  URg                  U5        X°l2        URi                  5         URj                  URl                  l5        U(       a  U Ro                  5         gg)	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.
TFr   N)ÚxposÚyposr?   rk   Ú )Úparent_styleÚerase_bgÚz_index)rz   rH   rR   r{   r|   )8rv   rz   r¼   Úenter_alternate_screenr¾   Úenable_bracketed_paster¿   Úreset_cursor_key_moderº   r½   Úenable_mouse_supportrÔ   rä   r   rt   r   ra   Ú	containerÚpreferred_heightr`   Ú	preferredrÌ   rk   rW   rÑ   rj   rÍ   rD   Úinvalidation_hashrÅ   r–   rÆ   rI   rÇ   rÃ   rÄ   r&   r•   r'   Úwrite_to_screenr   Údraw_all_floatsÚ
exit_styleÚappend_style_to_contentrˆ   rË   rÎ   rÐ   ÚcursorÚget_cursor_shaperÏ   Úset_cursor_shaper×   Úvisible_windowsrq   rÈ   )r—   ru   rq   ry   rv   Úneeds_mouse_supportr{   rw   rÐ   rk   Úlast_heightÚnew_cursor_shapes               r-   ÚrenderÚRenderer.renderN  s  € ð —‘ˆð ×× D×$=×$=Ø(,ˆDÔ%Ø×)Ñ)Ô+ð ×,×,Ø�K‰K×.Ñ.Ô0Ø,0ˆDÔ)ð ×*×*Ø�K‰K×-Ñ-Ô/Ø*.ˆDÔ'ð #×0Ñ0Ó2Ðæ t×'B×'BØ×'Ñ'Ô)Ø*.ˆDÕ'æ$¨×)D×)DØ×(Ñ(Ô*Ø*/ˆDÔ'ð �‰Ó ˆÜ“ˆØ"ˆÔä&›ˆð ××Ø—Y‘Y‰FÞà×%Ñ%×6Ñ6Ø—‘˜dŸi™ióç‰iñ ð 7;×6G×6G˜$×+Ñ+×2Ò2ÈQˆKÜØ×*Ñ*ØØ× Ñ ×1Ñ1°$·,±,ÀÇ	Á	ÓJ×TÑTóˆFô �VŸY™YÓ'ˆð �?‰?˜dÓ"Ø $ˆDÔð �J‰J×(Ñ(Ó*¨d×.CÑ.CÓCØ×'Ñ'×9Ñ9Ó;Ø×-Ñ-ó.à�‰ $×"8Ñ"8Ó8à $ˆDÔØ$(ˆDÔ!Ø+/ˆDÔ(à× Ñ Ñ(Ü$<Ø—
‘
×2Ñ2°C×4LÑ4Ló%ˆDÔ!ð ×'Ñ'Ñ/Ü+DØ×%Ñ%ó,ˆDÔ(ð !%§
¡
× <Ñ <Ó >ˆÔØ),×)AÑ)A×)SÑ)SÓ)UˆÔ&Ø!$§¡ˆÔà×Ñ×(Ñ(ØØÜ˜q q°·±ÀVÑLØØØð 	)ñ 	
ð 	×ÑÔ ð �>�>Ø×*Ñ*¨3¯>©>Ô:ô .AØØØØ×ÑØ�O‰OØ×ÑØ×ÑØØ×(Ñ(Ø#'×#8Ñ#8Ø#'×#?Ñ#?ØØ7;··˜DŸO™O×3Ò3ÈAñ.
Ñ*ˆÔ˜$Ô*ð #ÔØŒØ,Ôð Ÿ:™:×6Ñ6°sÓ;Ðà×#Ñ#Ñ+Ø×&Ñ&Ð*:Ó:à×#Ñ#Ð$4Ô5Ø&6Ô#ð 	�‰Œð &,×%;Ñ%;ˆ�
‰
Ô"æØ�J‰J�Lð r0   c                óN  • U R                   nUR                  U R                  R                  5        UR	                  U R                  R
                  5        UR                  5         UR                  5         UR                  5         UR                  5         U R                  US9  g)a"  
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)rv   rf   rË   r6   re   r7   ri   r.   rs   r×   rÈ   )r—   rØ   rv   s      r-   ÚeraseÚRenderer.eraseÞ  s}   € ð —‘ˆà×Ñ˜t×/Ñ/×1Ñ1Ô2Ø×Ñ˜×)Ñ)×+Ñ+Ô,Ø×ÑÔØ×ÑÔ!Ø×ÑÔ à�‰Œà�
‰
Ð*@ˆ
ÒAr0   c                óÀ   • U R                  5         U R                  nUR                  5         UR                  SS5        UR	                  5         U R                  5         g)z
Clear screen and go to 0,0
r   N)r1  rv   Úerase_screenÚcursor_gotor×   rõ   )r—   rv   s     r-   ÚclearÚRenderer.clearó  sI   € ð
 	�
‰
Œð —‘ˆà×ÑÔØ×Ñ˜1˜aÔ Ø�‰Œà×-Ñ-Õ/r0   )rÃ   r¾   r¿   rË   r¼   rÇ   rÏ   rÌ   rÍ   rÎ   rÅ   rÆ   rÑ   r½   rÄ   rÀ   r»   rÁ   rz   rÐ   rº   rv   rD   )FFN)rD   r   rv   r   rz   r¨   rº   r   r»   zCallable[[], None] | Noner]   r^   )FT)r¹   r¨   rØ   r¨   r]   r^   )r]   úScreen | None)r]   r¨   )r]   r_   r\   )rX   r_   r]   r^   )r3   )r	  r_   r]   r^   )F)ru   úApplication[Any]rq   r#   ry   r¨   r]   r^   )T)rØ   r¨   r]   r^   )r‹   rŒ   r�   rŽ   r�   rð   r˜   rÈ   ÚpropertyrÜ   rá   rç   rõ   rý   ró   r  r.  r1  r6  r�   r*   r0   r-   r$   r$   I  sþ   † ñð €Kð "Ø&+Ø@Dð&!àð&!ð ð&!ð ð	&!ð
 $ð&!ð %>ð&!ð 
õ&!öP/ðb ó!ó ð!ð óó ðð óHó ðHô;2ôzð. ó3ó ð3öð> FKðNØ#ðNØ-3ðNØ>BðNà	õNö`B÷*0r0   Nc                ó<  • [        U5      nU=(       d
    [        5       nU=(       d    U R                  5       nU R                  5         U R	                  5         Sn[        UR                  U5      nU H‡  tp‰n
Xx   nX¶:w  a)  U(       a  U R                  X´5        OU R                  5         UnSU;   a  U R                  U	5        MR  U	R                  SS5      n	U	R                  SS5      n	U R                  U	5        M‰     U R                  5         U R                  5         g)zL
Print a list of (style_str, text) tuples in the given style to the output.
Nz[ZeroWidthEscape]r4   r  Ú
r2   )r   r    Úget_default_color_depthr.   rs   r&   r•   rc   rb   Úreplacer@   r×   )rv   Úformatted_textrD   r–   rI   Ú	fragmentsÚ
last_attrsrH   rœ   Útextr  r�   s               r-   r%   r%     s
  € ô " .Ó1€IØ/×MÔ3KÓ3MÐØ×A ×!?Ñ!?Ó!A€Kð ×ÑÔØ
×ÑÔØ#€Jô 6Ø×%Ñ%Ð';óÐó  )Ðˆ	˜!Ø&Ñ1ˆð ÓÞØ×%Ñ% eÕ9à×'Ñ'Ô)Øˆ
ð  )Ó+Ø×Ñ˜TÖ"ð —<‘<  bÓ)ˆDð —<‘<  fÓ-ˆDØ�L‰L˜Öñ)  )ð. ×ÑÔØ
‡L�L…Nr0   )ru   r9  rv   r   rw   r   r>   r   rI   r   rx   r8  r,   z
str | Nonery   r¨   rz   r¨   rH   r&   rR   r'   r{   r   r|   r_   r]   ztuple[Point, str | None])NN)rv   r   r?  r   rD   r   r–   zStyleTransformation | NonerI   zColorDepth | Noner]   r^   )=r�   Ú
__future__r   Úasyncior   r   r   r   r   Úcollectionsr	   Úenumr
   Útypingr   r   r   r   r   Ú"prompt_toolkit.application.currentr   Úprompt_toolkit.cursor_shapesr   Úprompt_toolkit.data_structuresr   r   Úprompt_toolkit.filtersr   r   Úprompt_toolkit.formatted_textr   r   Ú$prompt_toolkit.layout.mouse_handlersr   Úprompt_toolkit.layout.screenr   r   r   Úprompt_toolkit.outputr   r   Úprompt_toolkit.stylesr   r   r    r!   Úprompt_toolkit.applicationr"   Úprompt_toolkit.layout.layoutr#   Ú__all__rˆ   Ú	ExceptionrŠ   r    r&   r¨   r'   r²   r$   r%   r*   r0   r-   Ú<module>rU     s’  ðñõ
 #ç GÕ GÝ Ý ß ?Õ ?å 6Ý 4ß 6ß :ß MÝ >ß DÑ Dß 4÷ó ö Ý6Ý3ð Øð€ð`#Ø	ð`#àð`#ð ð`#ð ð	`#ð
 ð`#ð #ð`#ð ð`#ð ð`#ð ð`#ð 5ð`#ð 6ð`#ð ð`#ð ð`#ð ô`#ôFE˜9ô Eô˜t C¨ JÑ/ô ô,  S¨$ Y¡ô ô:�$ô ÷x0ñ x0ð~ 8<Ø%)ð0Øð0à$ð0ð ð0ð 5ð	0ð
 #ð0ð 
ö0r0   