o
    ßñhQ  ã                   @  sn   d dl mZ d dlmZmZ d dlmZ d dlm	Z	 d dl
mZ er.d dlmZ d dlmZ G dd	„ d	ƒZd
S )é    )Úannotations)ÚTYPE_CHECKINGÚcast)ÚCode)Úgather_metrics)Ú
clean_text)ÚDeltaGenerator)ÚSupportsStrc                   @  s:   e Zd Zedƒ	dddddœddd„ƒZeddd„ƒZdS )Ú	CodeMixinÚcodeÚpythonFN)Úline_numbersÚ
wrap_linesÚheightÚbodyr	   Úlanguageú
str | Noner   Úboolr   r   ú
int | NoneÚreturnr   c                C  s>   t ƒ }t|ƒ|_|pd|_||_||_|r||_| j d|¡S )a~	  Display a code block with optional syntax highlighting.

        Parameters
        ----------
        body : str
            The string to display as code or monospace text.

        language : str or None
            The language that the code is written in, for syntax highlighting.
            This defaults to ``"python"``. If this is ``None``, the code will
            be plain, monospace text.

            For a list of available ``language`` values, see
            `react-syntax-highlighter
            <https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/master/AVAILABLE_LANGUAGES_PRISM.MD>`_
            on GitHub.

        line_numbers : bool
            An optional boolean indicating whether to show line numbers to the
            left of the code block. This defaults to ``False``.

        wrap_lines : bool
            An optional boolean indicating whether to wrap lines. This defaults
            to ``False``.

        height : int or None
            Desired height of the code block expressed in pixels. If ``height``
            is ``None`` (default), Streamlit sets the element's height to fit
            its content. Vertical scrolling within the element is enabled when
            the height does not accomodate all lines.

        Examples
        --------
        >>> import streamlit as st
        >>>
        >>> code = '''def hello():
        ...     print("Hello, Streamlit!")'''
        >>> st.code(code, language="python")

        .. output ::
            https://doc-code.streamlit.app/
            height: 220px

        >>> import streamlit as st
        >>> code = '''Is it a crown or boat?
        ...                         ii
        ...                       iiiiii
        ... WWw                 .iiiiiiii.                ...:
        ...  WWWWWWw          .iiiiiiiiiiii.         ........
        ...   WWWWWWWWWWw    iiiiiiiiiiiiiiii    ...........
        ...    WWWWWWWWWWWWWWwiiiiiiiiiiiiiiiii............
        ...     WWWWWWWWWWWWWWWWWWwiiiiiiiiiiiiii.........
        ...      WWWWWWWWWWWWWWWWWWWWWWwiiiiiiiiii.......
        ...       WWWWWWWWWWWWWWWWWWWWWWWWWWwiiiiiii....
        ...        WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWwiiii.
        ...           -MMMWWWWWWWWWWWWWWWWWWWWWWMMM-
        ... '''
        >>> st.code(code, language=None)

        .. output ::
            https://doc-code-ascii.streamlit.app/
            height: 380px
        Ú	plaintextr   )	Ú	CodeProtor   Ú	code_textr   Úshow_line_numbersr   r   ÚdgÚ_enqueue)Úselfr   r   r   r   r   Ú
code_proto© r   úK/var/www/vscode/kcb/lib/python3.10/site-packages/streamlit/elements/code.pyr      s   I

zCodeMixin.codec                 C  s
   t d| ƒS )zGet our DeltaGenerator.r   )r   )r   r   r   r   r   o   s   
zCodeMixin.dg)r   )r   r	   r   r   r   r   r   r   r   r   r   r   )r   r   )Ú__name__Ú
__module__Ú__qualname__r   r   Úpropertyr   r   r   r   r   r
      s    ýùQr
   N)Ú
__future__r   Útypingr   r   Ústreamlit.proto.Code_pb2r   r   Ústreamlit.runtime.metrics_utilr   Ústreamlit.string_utilr   Ústreamlit.delta_generatorr   Ústreamlit.type_utilr	   r
   r   r   r   r   Ú<module>   s   