
    G@d                     N    d Z ddlZ ej        e          Z G d de          ZdS )z
This module contains the editor extension API.

Adapted from pyqode/core/api/mode.py of the
`PyQode project <https://github.com/pyQode/pyQode>`_.
Original file:
<https://github.com/pyQode/pyqode.core/blob/master/pyqode/core/api/mode.py>
    Nc                       e Zd ZdZed             Zed             Zej        d             Zd Zd Z	d Z
d Zd	 Zd
 ZdS )EditorExtensiona  
    Base class for editor extensions.

    An extension is a "thing" that can be installed on an editor to add new
    behaviours or to modify its appearance.

    A panel (model child class) is added to an editor by using the
    PanelsManager:
        - :meth:
            `spyder.plugins.editor.widgets.codeeditor.CodeEditor.panels.append`

    Subclasses may/should override the following methods:

        - :meth:`spyder.api.EditorExtension.on_install`
        - :meth:`spyder.api.EditorExtension.on_uninstall`
        - :meth:`spyder.api.EditorExtension.on_state_changed`

    ..warning: The editor extension will be identified by its class name, this
    means that **there cannot be two editor extensions of the same type on the
    same editor instance!**
    c                     | j         S )z
        Returns a reference to the parent code editor widget.

        **READ ONLY**

        :rtype: spyder.plugins.editor.widgets.codeeditor.CodeEditor
        )_editorselfs    :lib/python3.11/site-packages/spyder/api/editorextension.pyeditorzEditorExtension.editor0   s     |    c                     | j         S )z
        Tells if the editor extension is enabled.

        :meth:`spyder.api.EditorExtension.on_state_changed` will be called as
        soon as the editor extension state changed.

        :type: bool
        )_enabledr   s    r	   enabledzEditorExtension.enabled;   s     }r   c                 X    || j         k    r|| _         |                     |           d S d S )N)r   on_state_changed)r   r   s     r	   r   zEditorExtension.enabledG   s8    dm###DM!!'***** $#r   c                 j    | j         j        | _        | j        | _        d| _        d| _        d| _        dS )z
        EditorExtension name/identifier.
        :class:`spyder.widgets.sourcecode.CodeEditor` uses that as the
        attribute key when you install a editor extension.
        FN)	__class____name__name__doc__descriptionr   r   	_on_closer   s    r	   __init__zEditorExtension.__init__M   s3     N+	<r   c                 V    t                               dt          |                      d S )Nz
%s.__del__)loggerdebugtyper   s    r	   __del__zEditorExtension.__del__Z   s"    \4::.....r   c                 "    || _         d| _        dS )a  
        Installs the extension on the editor.

        :param editor: editor widget instance
        :type editor: spyder.plugins.editor.widgets.codeeditor.CodeEditor

        .. note:: This method is called by editor when you install a
                  EditorExtension.
                  You should never call it yourself, even in a subclasss.

        .. warning:: Don't forget to call **super** when subclassing
        TN)r   r   )r   r
   s     r	   
on_installzEditorExtension.on_install]   s     r   c                 0    d| _         d| _        d| _        dS )z0Uninstalls the editor extension from the editor.TFN)r   r   r   r   s    r	   on_uninstallzEditorExtension.on_uninstallm   s    r   c                     dS )aT  
        Called when the enable state has changed.

        This method does not do anything, you may override it if you need
        to connect/disconnect to the editor's signals (connect when state is
        true and disconnect when it is false).

        :param state: True = enabled, False = disabled
        :type state: bool
        N )r   states     r	   r   z EditorExtension.on_state_changeds   s	     	r   c                     dS )a*  
        Clone the settings from another editor extension (same class).

        This method is called when splitting an editor widget.
        # TODO at the current estate this is not working

        :param original: other editor extension (must be the same class).

        .. note:: The base method does not do anything, you must implement
            this method for every new editor extension/panel (if you plan on
            using the split feature). You should also make sure any properties
            will be propagated to the clones.
        Nr#   )r   originals     r	   clone_settingszEditorExtension.clone_settings   s	     	r   N)r   
__module____qualname__r   propertyr
   r   setterr   r   r   r!   r   r'   r#   r   r	   r   r      s         ,   X 	 	 X	 ^+ + ^+
  / / /           r   r   )r   logging	getLoggerr   r   objectr   r#   r   r	   <module>r/      sl      
	8	$	$u u u u uf u u u u ur   