ó
    OÎh@K  ã                  ó°   • S SK Jr  S SKJr  S SK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JrJr  SS	KJrJr  SS
KJrJrJr  S/rSr " S S\5      rg)é    )Úannotations)ÚPoint)ÚFilterOrBoolÚ	to_filter)ÚKeyBindingsBase)Ú
MouseEventé   )Ú	ContainerÚScrollOffsets)ÚAnyDimensionÚ	DimensionÚsum_layout_dimensionsÚto_dimension)ÚMouseHandlerÚMouseHandlers)ÚCharÚScreenÚWritePositionÚScrollablePanei'  c            
      óx  • \ rS rSrSrSSS\SSSSSS4
                       SS jjrSS jrSS	 jrSS
 jr	SS jr
              SS jr      SS jr          SS jr          SS jr        S S jrS!S jrS"S jrS#S jr          S$S jr        S%S jrSrg)&r   é   aã  
Container widget that exposes a larger virtual screen to its content and
displays it in a vertical scrollbale region.

Typically this is wrapped in a large `HSplit` container. Make sure in that
case to not specify a `height` dimension of the `HSplit`, so that it will
scale according to the content.

.. note::

    If you want to display a completion menu for widgets in this
    `ScrollablePane`, then it's still a good practice to use a
    `FloatContainer` with a `CompletionsMenu` in a `Float` at the top-level
    of the layout hierarchy, rather then nesting a `FloatContainer` in this
    `ScrollablePane`. (Otherwise, it's possible that the completion menu
    is clipped.)

:param content: The content container.
:param scrolloffset: Try to keep the cursor within this distance from the
    top/bottom (left/right offset is not used).
:param keep_cursor_visible: When `True`, automatically scroll the pane so
    that the cursor (of the focused window) is always visible.
:param keep_focused_window_visible: When `True`, automatically scroll the
    pane so that the focused window is visible, or as much visible as
    possible if it doesn't completely fit the screen.
:param max_available_height: Always constraint the height to this amount
    for performance reasons.
:param width: When given, use this width instead of looking at the children.
:param height: When given, use this height instead of looking at the children.
:param show_scrollbar: When `True` display a scrollbar on the right.
NTÚ^Úvc                ó
  • Xl         U=(       d
    [        SSS9U l        [        U5      U l        [        U5      U l        XPl        X`l        Xpl        [        U5      U l	        [        U	5      U l
        X l        X°l        SU l        g )Nr	   )ÚtopÚbottomr   )Úcontentr   Úscroll_offsetsr   Úkeep_cursor_visibleÚkeep_focused_window_visibleÚmax_available_heightÚwidthÚheightÚshow_scrollbarÚdisplay_arrowsÚup_arrow_symbolÚdown_arrow_symbolÚvertical_scroll)Úselfr   r   r   r    r!   r"   r#   r$   r%   r&   r'   s               Úb/home/mande/repo/quber/.venv/lib/python3.13/site-packages/prompt_toolkit/layout/scrollable_pane.pyÚ__init__ÚScrollablePane.__init__4   sw   € ð ŒØ,×N´À!ÈAÑ0NˆÔÜ#,Ð-@Ó#AˆÔ Ü+4Ð5PÓ+QˆÔ(Ø$8Ô!ØŒ
ØŒÜ'¨Ó7ˆÔÜ'¨Ó7ˆÔØ.ÔØ!2Ôà ˆÕó    c                ó$   • SU R                   < S3$ )NzScrollablePane(Ú)©r   ©r)   s    r*   Ú__repr__ÚScrollablePane.__repr__P   s   € Ø  §¡Ñ 0°Ð2Ð2r-   c                ó8   • U R                   R                  5         g ©N)r   Úresetr1   s    r*   r6   ÚScrollablePane.resetS   s   € Ø�‰×ÑÕr-   c                óì   • U R                   b  [        U R                   5      $ U R                  R                  U5      nU R	                  5       (       a!  [        [        R                  " S5      U/5      $ U$ )Nr	   )r"   r   r   Úpreferred_widthr$   r   r   Úexact)r)   Úmax_available_widthÚcontent_widths      r*   r9   ÚScrollablePane.preferred_widthV   sb   € Ø�:‰:Ñ!Ü §
¡
Ó+Ð+ð Ÿ™×4Ñ4Ð5HÓIˆð ×Ñ× Ñ Ü(¬)¯/ª/¸!Ó*<¸mÐ)LÓMÐMàÐr-   c                óì   • U R                   b  [        U R                   5      $ U R                  5       (       a  US-  nU R                  R	                  XR
                  5      n[        SUR                  S9$ )Nr	   r   )ÚminÚ	preferred)r#   r   r$   r   Úpreferred_heightr!   r   r@   )r)   r"   r!   Ú	dimensions       r*   rA   ÚScrollablePane.preferred_heightd   sd   € Ø�;‰;Ñ"Ü §¡Ó,Ð,ð ×Ñ× Ñ à�Q‰JˆEà—L‘L×1Ñ1°%×9RÑ9RÓSˆ	ô ˜Q¨)×*=Ñ*=Ñ>Ð>r-   c                óÜ  • U R                  5       nU(       a  UR                  S-
  nOUR                  nU R                  R                  X€R                  5      R
                  n	[        X“R                  5      n	[        X�R                  5      n	[        [        SUS9S9n
UR                  U
l        [        SSX‰S9n[        5       nU R                  R                  U
UUUUU5        U
R                  5         SSKJn  U" 5       R$                  R&                  n U
R(                  U   nU R+                  UR                  U	UU
R,                  R/                  U5      5        U R3                  XX85        U R5                  X,X85        UR6                  nUR8                  n[        UR                  UU-   5      Ul        [        UR                  UUR                  -   5      Ul        U R;                  XU5        U
R                  (       a  SUl        U
R,                  R=                  5        H©  u  nnSUR>                  s=::  a  UR                  :  d  M)  O  M-  U R@                  URB                  s=::  a  UR                  U R@                  -   :  d  Mg  O  Mk  [E        UR>                  U-   URB                  U-   U R@                  -
  S	9UR,                  U'   M«     U
RF                  R=                  5        HT  u  nnU RI                  [E        UR>                  U-   URB                  U-   U R@                  -
  S	9U5      URF                  U'   MV     U(       a  U RK                  UU	U5        g
g
! [0         a     GNf = f)zx
Render scrollable pane content.

This works by rendering on an off-screen canvas, and copying over the
visible region.
r	   Ú )ÚcharÚstyle)Údefault_charr   )ÚxposÚyposr"   r#   )Úget_appT©ÚxÚyN)&r$   r"   r   rA   r!   r@   Úmaxr#   r?   r   r   Úshow_cursorr   r   Úwrite_to_screenÚdraw_all_floatsÚprompt_toolkit.applicationrK   ÚlayoutÚcurrent_windowÚ"visible_windows_to_write_positionsÚ_make_window_visibleÚcursor_positionsÚgetÚKeyErrorÚ_copy_over_screenÚ_copy_over_mouse_handlersrJ   rI   Ú_copy_over_write_positionsÚitemsrM   r(   rN   r   Úmenu_positionsÚ_clip_point_to_visible_areaÚ_draw_scrollbar)r)   ÚscreenÚmouse_handlersÚwrite_positionÚparent_styleÚerase_bgÚz_indexr$   Úvirtual_widthÚvirtual_heightÚtemp_screenÚtemp_write_positionÚtemp_mouse_handlersrK   Úfocused_windowÚvisible_win_write_posrJ   rI   ÚwindowÚpoints                       r*   rQ   ÚScrollablePane.write_to_screens   s  € ð ×,Ñ,Ó.ˆæØ*×0Ñ0°1Ñ4‰Mà*×0Ñ0ˆMð Ÿ™×6Ñ6Ø×4Ñ4ó
ç
‰)ð 	ô
 ˜^×-BÑ-BÓCˆÜ˜^×-FÑ-FÓGˆô ¬$°C¸|Ñ*LÑMˆØ"(×"4Ñ"4ˆÔÜ+Ø˜ -ñ
Ðô ,›oÐà�‰×$Ñ$ØØØØØØô	
ð 	×#Ñ#Ô%õ 	7á ›×)Ñ)×8Ñ8ˆð	Ø$/×$RÑ$RØñ%Ð!ð ×%Ñ%Ø×%Ñ%ØØ%Ø×,Ñ,×0Ñ0°Ó@ô	ð 	×Ñ˜v°NÔRð 	×&Ñ&Ø°ô	
ð
 ×"Ñ"ˆØ×"Ñ"ˆä˜6Ÿ<™<¨°Ñ)=Ó>ˆŒÜ˜FŸM™M¨4°.×2GÑ2GÑ+GÓHˆŒð 	×'Ñ'¨¸^ÔLà×"×"Ø!%ˆFÔð )×9Ñ9×?Ñ?ÖA‰MˆF�Eà�U—W‘WÕ3˜~×3Ñ3×3Ñ3Ø×(Ñ(Ø—7‘7õ?à ×'Ñ'¨$×*>Ñ*>Ñ>÷?ñ ?ô 38Ø—g‘g ‘n¨¯©°$©¸×9MÑ9MÑ(Mñ3�×'Ñ'¨Ó/ñ Bð )×7Ñ7×=Ñ=Ö?‰MˆF�EØ,0×,LÑ,LÜ˜Ÿ™ $™¨%¯'©'°D©.¸4×;OÑ;OÑ*OÑPØó-ˆF×!Ñ! &Ó)ñ @ö Ø× Ñ ØØØõð øôi ó 	Úð	ús   ÄM Í
M+Í*M+c                ó  • UR                   UR                  :  a  UR                  UR                  S9nUR                  UR                  :  a  UR                  UR                  S9nUR                   UR                  UR
                  -   :¼  a)  UR                  UR                  UR
                  -   S-
  S9nUR                  UR                  UR                  -   :¼  a)  UR                  UR                  UR                  -   S-
  S9nU$ )zF
Ensure that the cursor and menu positions always are always reported
)rM   )rN   r	   )rM   rI   Ú_replacerN   rJ   r"   r#   )r)   rp   rd   s      r*   r`   Ú*ScrollablePane._clip_point_to_visible_areaê   sá   € ð �7‰7�^×(Ñ(Ó(Ø—N‘N ^×%8Ñ%8�NÐ9ˆEØ�7‰7�^×(Ñ(Ó(Ø—N‘N ^×%8Ñ%8�NÐ9ˆEØ�7‰7�n×)Ñ)¨N×,@Ñ,@Ñ@Ó@Ø—N‘N ^×%8Ñ%8¸>×;OÑ;OÑ%OÐRSÑ%S�NÐTˆEØ�7‰7�n×)Ñ)¨N×,AÑ,AÑAÓAØ—N‘N ^×%8Ñ%8¸>×;PÑ;PÑ%PÐSTÑ%T�NÐUˆEàˆr-   c                ór  • UR                   nUR                  n[        UR                  5       H†  nUR                  XpR
                  -      nUR                  Xu-      n	UR                  XpR
                  -      n
UR                  Xu-      n[        U5       H  nXŒ   XœU-   '   XÊ;   d  M  X¬   X¼U-   '   M     Mˆ     g)zE
Copy over visible screen content and "zero width escape sequences".
N)rJ   rI   Úranger#   Údata_bufferr(   Úzero_width_escapes)r)   rb   rj   rd   rh   rJ   rI   rN   Útemp_rowÚrowÚtemp_zero_width_escapesrx   rM   s                r*   r[   Ú ScrollablePane._copy_over_screenû   s¾   € ð ×"Ñ"ˆØ×"Ñ"ˆä�~×,Ñ,Ö-ˆAØ"×.Ñ.¨q×3GÑ3GÑ/GÑHˆHØ×$Ñ$ Q¡XÑ.ˆCØ&1×&DÑ&DØ×(Ñ(Ñ(ñ'Ð#ð "(×!:Ñ!:¸1¹8Ñ!DÐä˜=Ö)�Ø (¡�˜‘H‘àÕ/Ø3JÑ3MÐ&¨4¡xÓ0ó	 *ò .r-   c                óL  ^ ^^^• UR                   mUR                  m0 mSUU UU4S jjnUR                  nUR                  n[        UR                  5       HJ  nX‡;   d  M
  XxT R
                  -      n	XhT-      n
[        U5       H  nX¹;   d  M
  U" X›   5      X«T-   '   M     ML     g)zÁ
Copy over mouse handlers from virtual screen to real screen.

Note: we take `virtual_width` because we don't want to copy over mouse
      handlers that we possibly have behind the scrollbar.
c                ó<   >^ • T T;  a  SU UUU4S jjnUTT '   TT    $ )z:Wrap mouse handler. Translate coordinates in `MouseEvent`.c                óð   >• [        [        U R                  R                  T-
  U R                  R                  TR
                  -   T-
  S9U R                  U R                  U R                  S9nT" U5        g )NrL   )ÚpositionÚ
event_typeÚbuttonÚ	modifiers)	r   r   r€   rM   rN   r(   r�   r‚   rƒ   )ÚeventÚ	new_eventÚhandlerr)   rI   rJ   s     €€€€r*   Únew_handlerÚYScrollablePane._copy_over_mouse_handlers.<locals>.wrap_mouse_handler.<locals>.new_handler.  sg   ø€ Ü *Ü!&Ø#Ÿn™n×.Ñ.°Ñ5Ø#Ÿn™n×.Ñ.°×1EÑ1EÑEÈÑLñ"ð $)×#3Ñ#3Ø$Ÿ|™|Ø"'§/¡/ñ!�Iñ ˜IÕ&r-   )r„   r   ÚreturnÚNone© )r†   r‡   Úmouse_handler_wrappersr)   rI   rJ   s   ` €€€€r*   Úwrap_mouse_handlerÚDScrollablePane._copy_over_mouse_handlers.<locals>.wrap_mouse_handler*  s.   ù€ àÐ4Ó4÷
'ò 
'ð 3>Ð& wÑ/Ø)¨'Ñ2Ð2r-   N)r†   r   r‰   r   )rJ   rI   rc   rv   r#   r(   )r)   rc   rl   rd   rh   r�   Úmouse_handlers_dictÚtemp_mouse_handlers_dictrN   Útemp_mouse_rowÚ	mouse_rowrM   rŒ   rI   rJ   s   `           @@@r*   r\   Ú(ScrollablePane._copy_over_mouse_handlers  s¬   û€ ð ×"Ñ"ˆØ×"Ñ"ˆð DFÐ÷	3ò 	3ð( -×;Ñ;ÐØ#6×#EÑ#EÐ ä�~×,Ñ,Ö-ˆAØÕ,Ø!9¸d×>RÑ>RÑ:RÑ!S�Ø/°D±Ñ9�	Ü˜}Ö-�AØÕ*Ù.@ÀÑARÓ.S˜	 d¡(Ó+ó .ò	 .r-   c                ó"  • UR                   nUR                  nUR                  R                  5        HY  u  pg[	        UR                  U-   UR                   U-   U R
                  -
  UR                  UR                  S9UR                  U'   M[     g)z#
Copy over window write positions.
)rI   rJ   r#   r"   N)rJ   rI   rV   r^   r   r(   r#   r"   )r)   rb   rj   rd   rJ   rI   ÚwinÚ	write_poss           r*   r]   Ú)ScrollablePane._copy_over_write_positionsI  s€   € ð ×"Ñ"ˆØ×"Ñ"ˆà)×LÑL×RÑRÖT‰NˆCÜ=JØ—^‘^ dÑ*Ø—^‘^ dÑ*¨T×-AÑ-AÑAð !×'Ñ'Ø—o‘oñ>ˆF×5Ñ5°cÓ:ò Ur-   c                ó6   • U R                   R                  5       $ r5   )r   Úis_modalr1   s    r*   r™   ÚScrollablePane.is_modal\  s   € Ø�|‰|×$Ñ$Ó&Ð&r-   c                ó6   • U R                   R                  5       $ r5   )r   Úget_key_bindingsr1   s    r*   rœ   ÚScrollablePane.get_key_bindings_  s   € Ø�|‰|×,Ñ,Ó.Ð.r-   c                ó   • U R                   /$ r5   r0   r1   s    r*   Úget_childrenÚScrollablePane.get_childrenb  s   € Ø—‘ˆ~Ðr-   c                óˆ  • SnX!-
  nU R                  5       (       ag  Ubd  U R                  nUR                  U-
  S-   UR                  -   nUR                  UR                  -
  n	[        XX5      n[        S[        Xi5      5      nU R                  5       (       aw  UR                  U::  a)  UR                  UR                  -   U-
  n
UR                  nO(UR                  n
UR                  UR                  -   U-
  n[        XZ5      n[        Xk5      nXV:”  a  UnU R                  U:”  a  X`l
        U R                  U:  a  XPl
        gg)a…  
Scroll the scrollable pane, so that this window becomes visible.

:param visible_height: Height of this `ScrollablePane` that is rendered.
:param virtual_height: Height of the virtual, temp screen.
:param visible_win_write_pos: `WritePosition` of the nested window on the
    temp screen.
:param cursor_position: The location of the cursor position of this
    window on the temp screen.
r   Nr	   )r   r   rN   r   r   rO   r?   r    r#   rJ   r(   )r)   Úvisible_heightri   rn   Úcursor_positionÚ
min_scrollÚ
max_scrollÚoffsetsÚcpos_min_scrollÚcpos_max_scrollÚwindow_min_scrollÚwindow_max_scrolls               r*   rW   Ú#ScrollablePane._make_window_visiblee  sV  € ð& ˆ
Ø#Ñ4ˆ
à×#Ñ#×%Ñ%àÑ*Ø×-Ñ-�à#×%Ñ%¨Ñ6¸Ñ:¸W¿^¹^ÑKð  ð #2×"3Ñ"3°g·k±kÑ"A�Ü  Ó=�
Ü  ¤C¨
Ó$DÓE�
à×+Ñ+×-Ñ-ð %×+Ñ+¨~Ó=à)×.Ñ.Ø+×2Ñ2ñ3à$ñ%ð "ð
 %:×$>Ñ$>Ñ!ð %:×$>Ñ$>Ð!à)×.Ñ.Ø+×2Ñ2ñ3à$ñ%ð "ô ˜ZÓ;ˆJÜ˜ZÓ;ˆJàÓ"Ø#ˆJð ×Ñ *Ó,Ø#-Ô Ø×Ñ *Ó,Ø#-Õ ð -r-   c           
     ó  ^^• UR                   nU R                  5       nU(       a  US-  n UR                   [        U5      -  nU R                  [        U5      -  n[	        [        U[        SXF-  5      5      5      m[	        XG-  5      mSUU4S jjnUR                  UR                  -   S-
  n	UR                  n
UR                  nU(       a   [        U R                  S5      Xº   U	'   U
S-  n
SnSnSnSn[        U5       HS  nS	nU" U5      (       a  U" US-   5      (       d  UnOUnOU" US-   5      (       a  UnOUn[        S
U5      Xº   U	'   U
S-  n
MU     U(       a  [        U R                  S5      Xº   U	'   gg! [         a     gf = f)zz
Draw the scrollbar on the screen.

Note: There is some code duplication with the `ScrollbarMargin`
      implementation.
é   r	   c                ó4   >• TU s=:*  =(       a    TT-   :*  $ s  $ )z/True if we should display a button on this row.r‹   )rz   Úscrollbar_heightÚscrollbar_tops    €€r*   Úis_scroll_buttonÚ8ScrollablePane._draw_scrollbar.<locals>.is_scroll_buttonÃ  s"   ø€ à$¨×OÓO¨}Ð?OÑ/OÑOÐOÑOÐOr-   zclass:scrollbar.arrowzclass:scrollbar.backgroundz*class:scrollbar.background,scrollbar.startzclass:scrollbar.buttonz$class:scrollbar.button,scrollbar.endÚ rE   N)rz   Úintr‰   Úbool)r#   r%   Úfloatr(   r´   r?   rO   rI   r"   rJ   rw   r   r&   rv   r'   ÚZeroDivisionError)r)   rd   Úcontent_heightrb   Úwindow_heightr%   Úfraction_visibleÚfraction_abover±   rI   rJ   rw   Úscrollbar_backgroundÚscrollbar_background_startÚscrollbar_buttonÚscrollbar_button_endÚirG   r¯   r°   s                     @@r*   ra   ÚScrollablePane._draw_scrollbar§  s¾  ù€ ð '×-Ñ-ˆØ×,Ñ,Ó.ˆæØ˜QÑˆMð7	Ø-×4Ñ4´u¸^Ó7LÑLÐØ!×1Ñ1´E¸.Ó4IÑIˆNä"Ü�M¤3 q¨-Ñ*JÓ#KÓLó Ðô   Ñ >Ó?ˆM÷
Pð Pð "×&Ñ&¨×)=Ñ)=Ñ=ÀÑAˆDØ!×&Ñ&ˆDØ ×,Ñ,ˆKö Ü*.Ø×(Ñ(Ð*Aó+�Ñ! $Ñ'ð ˜‘	�ð $@Ð Ø)UÐ&Ø7ÐØ#IÐ ä˜=Ö)�Ø�Ù# A×&Ñ&Ù+¨A°©E×2Ñ2ð !5™à 0™á'¨¨A©×.Ñ.Ø :™à 4˜ä*.¨s°EÓ*:�Ñ! $Ñ'Ø˜‘	’ñ! *ö& Ü*.Ø×*Ñ*Ð,Có+�Ñ! $Ò'ð øôY !ó 	Ùð	ús   ¬AE< Å<
F	ÆF	)r   r%   r'   r#   r   r    r!   r   r$   r&   r(   r"   )r   r
   r   zScrollOffsets | Noner   r   r    r   r!   r´   r"   r   r#   r   r$   r   r%   r   r&   Ústrr'   rÂ   r‰   rŠ   )r‰   rÂ   )r‰   rŠ   )r;   r´   r‰   r   )r"   r´   r!   r´   r‰   r   )rb   r   rc   r   rd   r   re   rÂ   rf   rµ   rg   z
int | Noner‰   rŠ   )rp   r   rd   r   r‰   r   )
rb   r   rj   r   rd   r   rh   r´   r‰   rŠ   )
rc   r   rl   r   rd   r   rh   r´   r‰   rŠ   )rb   r   rj   r   rd   r   r‰   rŠ   )r‰   rµ   )r‰   zKeyBindingsBase | None)r‰   zlist[Container])
r¢   r´   ri   r´   rn   r   r£   zPoint | Noner‰   rŠ   )rd   r   r¸   r´   rb   r   r‰   rŠ   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚMAX_AVAILABLE_HEIGHTr+   r2   r6   r9   rA   rQ   r`   r[   r\   r]   r™   rœ   rŸ   rW   ra   Ú__static_attributes__r‹   r-   r*   r   r      s7  † ñðF 04Ø,0Ø48Ø$8Ø"Ø#Ø'+Ø'+Ø"Ø!$ð!àð!ð -ð!ð *ð	!ð
 &2ð!ð "ð!ð ð!ð ð!ð %ð!ð %ð!ð ð!ð ð!ð 
õ!ô83ôôô?ðuàðuð &ðuð &ð	uð
 ðuð ðuð ðuð 
ôuðnØðØ,9ðà	ôð"NàðNð ðNð &ð	Nð
 ðNð 
ôNð61Tà%ð1Tð +ð1Tð &ð	1Tð
 ð1Tð 
ô1TðfØðØ+1ðØCPðà	ôô&'ô/ôð@.àð@.ð ð@.ð  -ð	@.ð
 &ð@.ð 
ô@.ðDGØ+ðGØ=@ðGØJPðGà	÷Gr-   N)Ú
__future__r   Úprompt_toolkit.data_structuresr   Úprompt_toolkit.filtersr   r   Úprompt_toolkit.key_bindingr   Úprompt_toolkit.mouse_eventsr   Ú
containersr
   r   rB   r   r   r   r   rc   r   r   rb   r   r   r   Ú__all__rÈ   r   r‹   r-   r*   Ú<module>rÑ      sD   ðÝ "å 0ß :Ý 6Ý 2ç 0ß SÓ Sß 7ß /Ñ /àÐ
€ð Ð ô[�Yõ [r-   