
    Je                     z    d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ  G d	 d
e      Zy)z
Console History Plugin.
    )Signal)PluginsSpyderDockablePlugin)on_plugin_availableon_plugin_teardown_)get_conf_path)HistoryConfigPage)HistoryWidgetc                       e Zd ZdZdZej                  ej                  gZej                  gZ
ej                  ZeZeZeZdZ e       Z	 d fd	Zed        Zd Zd Zd Z eej                  	      d
        Z eej                  	      d        Z eej                  	      d        Z eej                  	      d        Z eej                  	      d        Z  eej                  	      d        Z!d Z"d Z#d Z$d Z% xZ&S )
HistoryLogz
    History log plugin.
    
historylogFc                 Z    t         |   ||       | j                  t        d             y)zInitialization.z
history.pyN)super__init__add_historyr
   )selfparentconfiguration	__class__s      ?/usr/lib/python3/dist-packages/spyder/plugins/history/plugin.pyr   zHistoryLog.__init__.   s%    /|45    c                      t        d      S )NHistoryr    r   r   get_namezHistoryLog.get_name5   s    |r   c                     t        d      S )Nz,Provide command history for IPython Consolesr   r   s    r   get_descriptionzHistoryLog.get_description9   s    ?@@r   c                 $    | j                  d      S )Nhistory)create_iconr   s    r   get_iconzHistoryLog.get_icon<   s    	**r   c                 n    | j                         }|j                  j                  | j                         y N)
get_widgetsig_focus_changedconnect)r   widgets     r   on_initializezHistoryLog.on_initialize?   s(    "  (()?)?@r   )pluginc                 d    | j                  t        j                        }|j                  |        y r&   )
get_pluginr   Preferencesregister_plugin_preferencesr   preferencess     r   on_preferences_availablez#HistoryLog.on_preferences_availableC   s$    oog&9&9://5r   c                     | j                  t        j                        }|j                  j	                  | j
                         y r&   )r.   r   Consolesig_refreshedr)   refreshr   consoles     r   on_console_availablezHistoryLog.on_console_availableH   s,    //'//2%%dll3r   c                     | j                  t        j                        }|j                  j	                  | j
                         y r&   )r.   r   IPythonConsolesig_append_to_history_requestedr)   append_to_historyr   
ipyconsoles     r   on_ipyconsole_availablez"HistoryLog.on_ipyconsole_availableM   s3    __W%;%;<
22::""	$r   c                 d    | j                  t        j                        }|j                  |        y r&   )r.   r   r/   deregister_plugin_preferencesr1   s     r   on_preferences_teardownz"HistoryLog.on_preferences_teardownS   s$    oog&9&9:11$7r   c                     | j                  t        j                        }|j                  j	                  | j
                         y r&   )r.   r   r5   r6   
disconnectr7   r8   s     r   on_console_teardownzHistoryLog.on_console_teardownX   s,    //'//2((6r   c                     | j                  t        j                        }|j                  j	                  | j
                         y r&   )r.   r   r<   r=   rF   r>   r?   s     r   on_ipyconsole_teardownz!HistoryLog.on_ipyconsole_teardown]   s3    __W%;%;<
22==""	$r   c                     | j                         }| j                         }| j                         j                  ||       y r&   )get_color_schemeget_fontr'   update_font)r   color_schemefonts      r   rM   zHistoryLog.update_fontc   s2    ,,.}}%%dL9r   c                 @    | j                         j                          y)z&
        Refresh main widget.
        N)r'   r7   r   s    r   r7   zHistoryLog.refreshj   s     	!!#r   c                 B    | j                         j                  |       y)z}
        Create history file.

        Parameters
        ----------
        filename: str
            History file.
        N)r'   r   )r   filenames     r   r   zHistoryLog.add_historyp   s     	%%h/r   c                 D    | j                         j                  ||       y)z
        Append command to history file.

        Parameters
        ----------
        filename: str
            History file.
        command: str
            Command to append to history file.
        N)r'   r>   )r   rR   commands      r   r>   zHistoryLog.append_to_history{   s     	++Hg>r   )NN)'__name__
__module____qualname____doc__NAMEr   r/   r5   REQUIRESr<   OPTIONALTABIFYr   WIDGET_CLASSCONF_SECTIONr   CONF_WIDGET_CLASS	CONF_FILEr   r(   r   staticmethodr   r    r$   r+   r   r3   r:   rA   r   rD   rG   rI   rM   r7   r   r>   __classcell__)r   s   @r   r   r      sT    D##W__5H&&'H##F LL)I 
6  A+A  3 346 56 04 14  6 67$ 8$
 w2238 48 w/7 07 w556$ 7$
:$	0?r   r   N)rX   qtpy.QtCorer   spyder.api.pluginsr   r   )spyder.api.plugin_registration.decoratorsr   r   spyder.api.translationsr	   spyder.config.baser
   spyder.plugins.history.confpager   spyder.plugins.history.widgetsr   r   r   r   r   <module>rj      s4   
  =- % , = 8n?% n?r   