
    ^h(                        S 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JrJr  SSKJr  SS	KJr  \(       a  SS
KJr  / SQr " S S\S9r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)zQ
Margin implementations for a :class:`~prompt_toolkit.layout.containers.Window`.
    )annotations)ABCMetaabstractmethod)TYPE_CHECKINGCallable)FilterOrBool	to_filter)StyleAndTextTuplesfragment_list_to_textto_formatted_text)
get_cwidth   )	UIContent)WindowRenderInfo)MarginNumberedMarginScrollbarMarginConditionalMarginPromptMarginc                  P    \ rS rSrSr\SS j5       r\        SS j5       rSrg)	r       z
Base interface for a margin.
c                    g)z
Return the width that this margin is going to consume.

:param get_ui_content: Callable that asks the user control to create
    a :class:`.UIContent` instance. This can be used for instance to
    obtain the number of lines.
r    selfget_ui_contents     W/home/james-whalen/.local/lib/python3.13/site-packages/prompt_toolkit/layout/margins.py	get_widthMargin.get_width%   s         c                    / $ )aS  
Creates a margin.
This should return a list of (style_str, text) tuples.

:param window_render_info:
    :class:`~prompt_toolkit.layout.containers.WindowRenderInfo`
    instance, generated after rendering and copying the visible part of
    the :class:`~prompt_toolkit.layout.controls.UIControl` into the
    :class:`~prompt_toolkit.layout.containers.Window`.
:param width: The width that's available for this margin. (As reported
    by :meth:`.get_width`.)
:param height: The height that's available for this margin. (The height
    of the :class:`~prompt_toolkit.layout.containers.Window`.)
r   r   window_render_infowidthheights       r   create_marginMargin.create_margin0   s	    $ 	r    r   Nr   zCallable[[], UIContent]returnintr#   r   r$   r*   r%   r*   r)   r
   )	__name__
__module____qualname____firstlineno____doc__r   r   r&   __static_attributes__r   r    r   r   r       sO       "2;>HK	 r    r   )	metaclassc                  V    \ rS rSrSr S     S	S jjrS
S jr        SS jrSrg)r   E   z
Margin that displays the line numbers.

:param relative: Number relative to the cursor position. Similar to the Vi
                 'relativenumber' option.
:param display_tildes: Display tildes after the end of the document, just
    like Vi does.
c                D    [        U5      U l        [        U5      U l        g N)r	   relativedisplay_tildes)r   r7   r8   s      r   __init__NumberedMargin.__init__O   s     "(+'7r    c                V    U" 5       R                   n[        S[        U 5      S-   5      $ )N   r   )
line_countmaxlen)r   r   r=   s      r   r   NumberedMargin.get_widthU   s)    #%00
1cZL*Q.//r    c                   U R                  5       nSnSnUR                  R                  R                  n/ nS n	[	        UR
                  5       H  u  pX:w  a  Uc  OX:X  aJ  U(       a  UR                  USUS-   -  45        OhUR                  USUS-   -  R                  U5      45        O?U(       a  [        X-
  5      S-
  nUR                  USUS-   -  R                  U5      45        Un	UR                  S5        M     U R                  5       (       a7  W
UR                  :  a'  UR                  S5        U
S-  n
XR                  :  a  M'  U$ )Nzclass:line-numberzclass:line-number.currentz%ir   z%i  
)zclass:tildez~
)r7   
ui_contentcursor_positiony	enumeratedisplayed_linesappendrjustabsr8   window_height)r   r#   r$   r%   r7   stylestyle_currentcurrent_linenoresultlast_linenorG   linenos               r   r&   NumberedMargin.create_marginY   sH    ==?#3 ,66FFHH &("#5#E#EFIA$>-}dfqj6I&JK*Ufqj-A,H,H,OP
  !$V%<!=!AMM55FQJ+?*F*Fu*M"NO KMM*%- G2   (66645Q 666 r    )r8   r7   N)FF)r7   r   r8   r   r)   Noner(   r+   	r,   r-   r.   r/   r0   r9   r   r&   r1   r   r    r   r   r   E   sU     NS8$8>J8	80-"2-;>-HK-	-r    r   c                  F    \ rS rSrSrSS jrS	S jr        S
S jrSrg)r      zB
Wrapper around other :class:`.Margin` classes to show/hide them.
c                0    Xl         [        U5      U l        g r6   )marginr	   filter)r   rZ   r[   s      r   r9   ConditionalMargin.__init__   s    'r    c                d    U R                  5       (       a  U R                  R                  U5      $ g)Nr   )r[   rZ   r   r   s     r   r   ConditionalMargin.get_width   s%    ;;==;;((88r    c                v    U(       a1  U R                  5       (       a  U R                  R                  XU5      $ / $ r6   )r[   rZ   r&   r"   s       r   r&   ConditionalMargin.create_margin   s.     T[[]];;,,-?OOIr    )r[   rZ   N)rZ   r   r[   r   r)   rU   r(   r+   rV   r   r    r   r   r      s6    ("2;>HK	r    r   c                  ^    \ rS rSrSr   S       S	S jjrS
S jr        SS jrSrg)r      zW
Margin displaying a scrollbar.

:param display_arrows: Display scroll up/down arrows.
c                <    [        U5      U l        X l        X0l        g r6   )r	   display_arrowsup_arrow_symboldown_arrow_symbol)r   rd   re   rf   s       r   r9   ScrollbarMargin.__init__   s     (7.!2r    c                    g)Nr   r   r   s     r   r   ScrollbarMargin.get_width   s    r    c           
     ^  ^^ UR                   nUR                  nU R                  5       nU(       a  US-  n [        UR                  5      [        U5      -  nUR                  [        U5      -  n[        [        U[        SXW-  5      5      5      m[        XX-  5      mSUU4S jjn	/ n
U(       a  U
R                  SU R                  4S/5        SnSnSnS	n[        U5       H  nU	" U5      (       a8  U	" US-   5      (       d  U
R                  US
45        OKU
R                  US
45        O7U	" US-   5      (       a  U
R                  US
45        OU
R                  US
45        U
R                  S5        M     U(       a  U
R                  SU R                  45        U
$ ! [         a    / s $ f = f)N   r   c                4   > TU s=:*  =(       a    TT-   :*  $ s  $ )z/True if we should display a button on this row.r   )rowscrollbar_heightscrollbar_tops    r   is_scroll_button7ScrollbarMargin.create_margin.<locals>.is_scroll_button   s"    $OO}?O/OOOOOr    zclass:scrollbar.arrow)zclass:scrollbarrD   zclass:scrollbar.backgroundz*class:scrollbar.background,scrollbar.startzclass:scrollbar.buttonz$class:scrollbar.button,scrollbar.end rB   )rm   r*   r)   bool)content_heightrM   rd   r?   rI   floatvertical_scrollr*   minr>   extendre   rangerJ   rf   ZeroDivisionError)r   r#   r$   r%   rt   rM   rd   fraction_visiblefraction_aboverp   rQ   scrollbar_backgroundscrollbar_background_startscrollbar_buttonscrollbar_button_endirn   ro   s                   @@r   r&   ScrollbarMargin.create_margin   s    ,::*88,,.QM5	"#5#E#EFJ   0??%BWWN"M3q-*J#KL    >?M
P P
 *,F0$2F2FG1 $@ )U&7#I =)#A&&+AE22 ';S&AB'7&=>'A..'A3&GH';S&ABj) *  68N8NOPMW ! 	I	s   A'F F,+F,)rd   rf   re   N)F^v)rd   r   re   strrf   r   r)   rU   r(   r+   rV   r   r    r   r   r      sg     (-"!$	3$3 3 	3
 
3?"2?;>?HK?	?r    r   c                  V    \ rS rSrSr S     S	S jjrS
S jr        SS jrSrg)r      ab  
[Deprecated]

Create margin that displays a prompt.
This can display one prompt at the first line, and a continuation prompt
(e.g, just dots) on all the following lines.

This `PromptMargin` implementation has been largely superseded in favor of
the `get_line_prefix` attribute of `Window`. The reason is that a margin is
always a fixed width, while `get_line_prefix` can return a variable width
prefix in front of every line, making it more powerful, especially for line
continuations.

:param get_prompt: Callable returns formatted text or a list of
    `(style_str, type)` tuples to be shown as the prompt at the first line.
:param get_continuation: Callable that takes three inputs. The width (int),
    line_number (int), and is_soft_wrap (bool). It should return formatted
    text or a list of `(style_str, type)` tuples for the next lines of the
    input.
Nc                    Xl         X l        g r6   )
get_promptget_continuation)r   r   r   s      r   r9   PromptMargin.__init__  s     % 0r    c                J    [        U R                  5       5      n[        U5      $ )z Width to report to the `Window`.)r   r   r   )r   r   texts      r   r   PromptMargin.get_width  s      %T__%67$r    c                   U R                   n/ nUR                  [        U R                  5       5      5        U(       aN  S nUR                  SS   H9  nUR                  S5        UR                  [        U" X'Xv:H  5      5      5        UnM;     U$ )Nr   rB   )r   rx   r   r   rI   rJ   )r   r#   r$   r%   r   rQ   last_yrG   s           r   r&   PromptMargin.create_margin  s      00%' 	'(9:; F'77;j)%&6u&MN  < r    )r   r   r6   )r   z Callable[[], StyleAndTextTuples]r   z5None | Callable[[int, int, bool], StyleAndTextTuples]r)   rU   r(   r+   rV   r   r    r   r   r      sX    2 >B	141;1
 
1 "2;>HK	r    r   N)r0   
__future__r   abcr   r   typingr   r   prompt_toolkit.filtersr   r	   prompt_toolkit.formatted_textr
   r   r   prompt_toolkit.utilsr   controlsr   
containersr   __all__r   r   r   r   r   r   r    r   <module>r      sz    # ' * : 
 , ,"w "JAV AH 0Sf Sl96 9r    