
    Je                     J    d Z ddlZ ej                  e      Z G d de      Zy)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                   x    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y)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    </usr/lib/python3/dist-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                 T    || j                   k7  r|| _         | j                  |       y y )N)r   on_state_changed)r   r   s     r	   r   zEditorExtension.enabledG   s(    dmm##DM!!'* $r   c                     | j                   j                  | _        | j                  | _        d| _        d| _        d| _        y)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   s6     NN++	<<r   c                 B    t         j                  dt        |              y )Nz
%s.__del__)loggerdebugtyper   s    r	   __del__zEditorExtension.__del__Z   s    \4:.r   c                      || _         d| _        y)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                 .    d| _         d| _        d| _        y)z0Uninstalls the editor extension from the editor.TFN)r   r   r   r   s    r	   on_uninstallzEditorExtension.on_uninstallm   s    r   c                      y)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                      y)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      se    ,   	 	 ^^+ +
/ r   r   )r   logging	getLoggerr   r   objectr   r#   r   r	   <module>r/      s1     
		8	$uf ur   