
    Be                        d Z ddlmZ ddlmZmZmZmZ ddlZddl	m
Z
 ddl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 ddl	mZ  G d de          Z G d de          ZdS )z-
Defines the CodeEditor widget based on Ace.
    )annotations)TYPE_CHECKINGClassVarMappingOptionalN)JupyterComm   )
ace_themes)	lazy_load)
deprecated   )Widget)Document)Model)Commc                  ^    e Zd ZU dZ ej        g d          Z ej        d          Z ej        dd          Z	 ej
        dd	          Z ej
        dd
          Z ej        d ee          d          Z ej        d          ZdddZded<    fdZ	 	 d"d# fdZd$d!Z xZS )%
CodeEditora  
    The CodeEditor widget allows displaying and editing code in the
    powerful Ace editor.

    Reference: https://panel.holoviz.org/reference/widgets/CodeEditor.html

    :Example:

    >>> CodeEditor(value=py_code, language='python', theme='monokai')
    z2
        List of annotations to add to the editor.)defaultdocz&Filename from which to deduce language)r   textzLanguage of the editorFz,
        Whether to show the a print margin.zF
        Define if editor content can be modified. Alias for disabled.chromezTheme of the editor)r   objectsr   z'State of the current code in the editorcodeN)valuenamez"ClassVar[Mapping[str, str | None]]_renamec                   d|v r|d         |d<   nd|v r|d         |d<    t                      j        di | | j                            | j                            | j        ddg                     |                     | dd           d S )NreadonlydisabledT)r   bidirectional )super__init___internal_callbacksappendparamwatch_update_disabledjslinkselfparams	__class__s     8lib/python3.11/site-packages/panel/widgets/codeeditor.pyr#   zCodeEditor.__init__9   s    !'
!3F:6!!!'
!3F:""6""" ''JT2Z4LMM	
 	
 	
 	D:TBBBBB    r   r   rootOptional[Model]parentcommOptional[Comm]returnr   c                    | j         ,t          ddt          |t                    |d          | _         t	                                          ||||          S )Nzpanel.models.aceAcePlot
codeeditor)ext)_widget_typer   
isinstancer   r"   
_get_model)r+   r   r0   r2   r3   r-   s        r.   r<   zCodeEditor._get_modelD   s[     $ )"Iz$/L/L,! ! !D ww!!#tVT:::r/   eventsparam.parameterized.Eventc                n    |D ]1}|j         dk    r|j        | _        |j         dk    r|j        | _        2d S )Nr   r   )r   newr   r   )r+   r=   events      r.   r(   zCodeEditor._update_disabledO   sJ     	* 	*EzZ'' %	z)) %			* 	*r/   )NNN)
r   r   r0   r1   r2   r1   r3   r4   r5   r   )r=   r>   )__name__
__module____qualname____doc__r&   Listr   StringfilenamelanguageBooleanprint_marginr   ObjectSelectorlistr
   themer   r   __annotations__r#   r<   r(   __classcell__r-   s   @r.   r   r      sw        	 	 %*R .5 6 6 6K u| HIIIHu|F0HIIIH 5= 5/ 0 0 0L u}U 1I J J JH !E 44
;K;K%:< < <E ELFGGGE<BD2Q2QGQQQQ	C 	C 	C 	C 	C 6:?C	; 	; 	; 	; 	; 	; 	;* * * * * * * *r/   r   c                       e Zd Z fdZ xZS )Acec                \    t          ddd            t                      j        di | d S )Nz1.4rS   r   r!   )r   r"   r#   r*   s     r.   r#   zAce.__init__X   s8    5%...""6"""""r/   )rB   rC   rD   r#   rP   rQ   s   @r.   rS   rS   W   s8        # # # # # # # # #r/   rS   )rE   
__future__r   typingr   r   r   r   r&   pyviz_commsr   models.enumsr
   utilr   util.warningsr   baser   bokeh.documentr   bokeh.modelr   r   r   rS   r!   r/   r.   <module>r^      sa    # " " " " "             # # # # # # % % % % % %       & & & & & &       !''''''!!!!!!      ;* ;* ;* ;* ;* ;* ;* ;*|# # # # #* # # # # #r/   