
     h(                       d Z ddlmZ ddlmZmZ ddlmZmZm	Z	 ddl
mZmZ ddlmZmZmZ ddlmZ dd	lmZ erdd
lmZ g dZ G d de          Z G d de          Z G d de          Z G d de          Z G d de          ZdS )zQ
Margin implementations for a :class:`~prompt_toolkit.layout.containers.Window`.
    )annotations)ABCMetaabstractmethod)TYPE_CHECKINGCallableOptional)FilterOrBool	to_filter)StyleAndTextTuplesfragment_list_to_textto_formatted_text)
get_cwidth   )	UIContent)WindowRenderInfo)MarginNumberedMarginScrollbarMarginConditionalMarginPromptMarginc                  B    e Zd ZdZedd            Zedd            ZdS )r   z&
    Base interface for a margin.
    get_ui_contentCallable[[], UIContent]returnintc                    dS )a  
        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    selfr   s     Y/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/prompt_toolkit/layout/margins.py	get_widthzMargin.get_width$   s	     q    window_render_infor   widthheightr   c                    g S )a  
        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   r#   r$   r%   s       r    create_marginzMargin.create_margin/   s	    $ 	r"   Nr   r   r   r   r#   r   r$   r   r%   r   r   r   )__name__
__module____qualname____doc__r   r!   r(   r   r"   r    r   r      s^             ^    ^  r"   r   )	metaclassc                  .    e Zd ZdZ	 dddZddZddZdS )r   a  
    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.
    Frelativer	   display_tildesr   Nonec                V    t          |          | _        t          |          | _        d S N)r
   r1   r2   )r   r1   r2   s      r    __init__zNumberedMargin.__init__N   s)     "(++'77r"   r   r   r   c                f     |            j         }t          dt          d|z            dz             S )N   z%sr   )
line_countmaxlen)r   r   r9   s      r    r!   zNumberedMargin.get_widthT   s4    #^%%0
1c$+,,q0111r"   r#   r   r$   r%   r   c                   |                                  }d}d}|j        j        j        }g }d }	t	          |j                  D ]\  }
}||	k    r|n||k    rQ|r|                    |d|dz   z  f           nx|                    |d|dz   z                      |          f           nG|rt          ||z
            dz
  }|                    |d|dz   z                      |          f           |}	|                    d           | 	                                r0|
|j
        k     r%|                    d           |
dz  }
|
|j
        k     %|S )Nzclass:line-numberzclass:line-number.currentz%ir   z%i  
)zclass:tildez~
)r1   
ui_contentcursor_positiony	enumeratedisplayed_linesappendrjustabsr2   window_height)r   r#   r$   r%   r1   stylestyle_currentcurrent_linenoresultlast_linenorB   linenos               r    r(   zNumberedMargin.create_marginX   s    ==??#3 ,6FH &("#5#EFF 	& 	&IAv$$>~-- }dfqj6I&JKKKK*Ufqj-A,H,H,O,OP   
   B!$Vn%<!=!=!AMM55FQJ+?*F*Fu*M*M"NOOO KMM*%%%%    	(6664555Q (666 r"   N)FF)r1   r	   r2   r	   r   r3   r)   r*   r+   r,   r-   r.   r6   r!   r(   r   r"   r    r   r   D   sf          NS8 8 8 8 82 2 2 2- - - - - -r"   r   c                  *    e Zd ZdZddZddZddZdS )r   zJ
    Wrapper around other :class:`.Margin` classes to show/hide them.
    marginr   filterr	   r   r3   c                <    || _         t          |          | _        d S r5   )rQ   r
   rR   )r   rQ   rR   s      r    r6   zConditionalMargin.__init__   s    ''r"   r   r   r   c                b    |                                  r| j                            |          S dS )Nr   )rR   rQ   r!   r   s     r    r!   zConditionalMargin.get_width   s-    ;;== 	;((8881r"   r#   r   r$   r%   r   c                j    |r0|                                  r| j                            |||          S g S r5   )rR   rQ   r(   r'   s       r    r(   zConditionalMargin.create_margin   s;      	T[[]] 	;,,-?OOOIr"   N)rQ   r   rR   r	   r   r3   r)   r*   rO   r   r"   r    r   r      sZ         ( ( ( (        r"   r   c                  2    e Zd ZdZ	 	 	 dddZddZddZdS )r   zc
    Margin displaying a scrollbar.

    :param display_arrows: Display scroll up/down arrows.
    F^vdisplay_arrowsr	   up_arrow_symbolstrdown_arrow_symbolr   r3   c                J    t          |          | _        || _        || _        d S r5   )r
   rY   rZ   r\   )r   rY   rZ   r\   s       r    r6   zScrollbarMargin.__init__   s*     (77.!2r"   r   r   r   c                    dS )Nr   r   r   s     r    r!   zScrollbarMargin.get_width   s    qr"   r#   r   r$   r%   r   c           
     p   |j         }|j        }|                                 }|r|dz  }	 t          |j                  t          |          z  }|j        t          |          z  }t          t          |t          d||z                                t          ||z            dfd}	g }
|r|

                    d| j        fd	g           d
}d}d}d}t          |          D ]} |	|          r> |	|dz             s|
                    |df           nU|
                    |df           n= |	|dz             r|
                    |df           n|
                    |df           |
                    d           |r|
                    d| j        f           |
S # t          $ r g cY S w xY w)N   r   rowr   r   boolc                *    | cxk    oz   k    nc S )z/True if we should display a button on this row.r   )ra   scrollbar_heightscrollbar_tops    r    is_scroll_buttonz7ScrollbarMargin.create_margin.<locals>.is_scroll_button   s+    $OOOO}?O/OOOOOOr"   zclass:scrollbar.arrow)zclass:scrollbarr?   zclass:scrollbar.backgroundz*class:scrollbar.background,scrollbar.startzclass:scrollbar.buttonz$class:scrollbar.button,scrollbar.end r=   )ra   r   r   rb   )content_heightrH   rY   r;   rD   floatvertical_scrollr   minr:   extendrZ   rangerE   r\   ZeroDivisionError)r   r#   r$   r%   rh   rH   rY   fraction_visiblefraction_aboverf   rL   scrollbar_backgroundscrollbar_background_startscrollbar_buttonscrollbar_button_endird   re   s                   @@r    r(   zScrollbarMargin.create_margin   sg    ,:*8,,.. 	QM5	"#5#EFFJ J   0?%BWBWWN"M3q-:J*J#K#KLL      >??M
P P P P P P P
 *,F 0$2FG1   $@ )U&7#I =)) * *##A&& C++AE22 ? ';S&ABBBB'7&=>>>>''A.. C'A3&GHHHH';S&ABBBj))))  Q68NOPPPMW ! 	 	 	III	s   A;F& &F54F5N)FrW   rX   )rY   r	   rZ   r[   r\   r[   r   r3   r)   r*   rO   r   r"   r    r   r      sj          (-"!$	3 3 3 3 3   ? ? ? ? ? ?r"   r   c                  .    e Zd ZdZ	 ddd	ZddZddZdS )r   a  
    [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.
    N
get_prompt Callable[[], StyleAndTextTuples]get_continuation5None | Callable[[int, int, bool], StyleAndTextTuples]r   r3   c                "    || _         || _        d S r5   )rw   ry   )r   rw   ry   s      r    r6   zPromptMargin.__init__  s     % 0r"   r   r   r   c                b    t          |                                           }t          |          S )z Width to report to the `Window`.)r   rw   r   )r   r   texts      r    r!   zPromptMargin.get_width  s)     %T__%6%677$r"   r#   r   r$   r%   r   c                <   | j         }g }|                    t          |                                                      |r\d }|j        dd          D ]J}|                    d           |                    t           |||||k                                   |}K|S )Nr   r=   )ry   rl   r   rw   rD   rE   )r   r#   r$   r%   ry   rL   last_yrB   s           r    r(   zPromptMargin.create_margin  s      0%' 	'(9(9::;;;  	F'7;  j)))%&6&6uaf&M&MNN   r"   r5   )rw   rx   ry   rz   r   r3   r)   r*   rO   r   r"   r    r   r      se         2 >B	1 1 1 1 1            r"   r   N)r.   
__future__r   abcr   r   typingr   r   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      s    # " " " " " ' ' ' ' ' ' ' ' 4 4 4 4 4 4 4 4 4 4 : : : : : : : :         
 , + + + + +       -,,,,,,  " " " " "w " " " "JA A A A AV A A AH       0S S S S Sf S S Sl9 9 9 9 96 9 9 9 9 9r"   