o
    û›hŽ  ã                   @   sº   d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
 ddd„Zd d
d	„Zd!dd„Zd"dd„Zd#dd„Zd$dd„Zd%dd„Zd&dd„Zd'dd„Zd(dd„Zd)dd„ZdS )*z™ 'editor' hooks for common editors that work well with ipython

They should honor the line number argument, at least.

Contributions are *very* welcome.
é    N)Úget_ipython)ÚTryNext)Ú	py3compatFc                    s*   d‡ ‡fdd„	}t ƒ  d|¡ ˆ t ƒ _dS )ay  Installs the editor that is called by IPython for the %edit magic.

    This overrides the default editor, which is generally set by your EDITOR
    environment variable or is notepad (windows) or vi (linux). By supplying a
    template string `run_template`, you can control how the editor is invoked
    by IPython -- (e.g. the format in which it accepts command line options)

    Parameters
    ----------
    template : basestring
        run_template acts as a template for how your editor is invoked by
        the shell. It should contain '{filename}', which will be replaced on
        invocation with the file name, and '{line}', $line by line number
        (or 0) to invoke the file with.
    wait : bool
        If `wait` is true, wait until the user presses enter before returning,
        to facilitate non-blocking editors that exit immediately after
        the call.
    r   c                    sv   |d u rd}ˆ j t |¡|d�}td|ƒ tj d¡r t |¡}tj	|dd�}| 
¡ dkr0tƒ ‚ˆr9t d¡ d S d S )Nr   )ÚfilenameÚlineú>ÚwinT)ÚshellzPress Enter when done editing:)ÚformatÚshlexÚquoteÚprintÚsysÚplatformÚ
startswithÚsplitÚ
subprocessÚPopenÚwaitr   r   Úinput)Úselfr   r   ÚcmdÚproc©Útemplater   © úMc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/lib/editorhooks.pyÚcall_editor.   s   

ÿz#install_editor.<locals>.call_editorÚeditorN)r   )r   Zset_hookr   )r   r   r   r   r   r   Úinstall_editor   s   r   Úkomodoc                 C   s   t | d dd� dS )z Activestate Komodo [Edit] z -l {line} {filename}T)r   N©r   ©Úexer   r   r   r    B   s   Úscitec                 C   ó   t | d ƒ dS )z SciTE or Sc1 z {filename} -goto:{line}Nr!   r"   r   r   r   r$   G   ó   ú	notepad++c                 C   r%   )z/ Notepad++ http://notepad-plus.sourceforge.net z -n{line} {filename}Nr!   r"   r   r   r   ÚnotepadplusplusL   r&   r(   Újedc                 C   r%   )z& JED, the lightweight emacsish editor ú +{line} {filename}Nr!   r"   r   r   r   r)   Q   r&   Úidlec                 C   s<   | du rddl }tj |j¡}tj |d¡} t| d ƒ dS )z£ Idle, the editor bundled with python

    Parameters
    ----------
    exe : str, None
        If none, should be pretty smart about finding the executable.
    Nr   zidle.pyz {filename})ÚidlelibÚosÚpathÚdirnameZ__filename__Újoinr   )r#   r,   Úpr   r   r   r+   V   s
   Úmatec                 C   r%   )z TextMate, the missing editorz -w -l {line} {filename}Nr!   r"   r   r   r   r2   g   s   Úemacsc                 C   ó   t | d ƒ d S )Nr*   r!   r"   r   r   r   r3   r   ó   Ú	gnuclientc                 C   r4   )Nz -nw +{line} {filename}r!   r"   r   r   r   r6   v   r5   úcedt.exec                 C   r4   )Nz /L:{line} {filename}r!   r"   r   r   r   Úcrimson_editorz   r5   r8   Úkatec                 C   r4   )Nz -u -l {line} {filename}r!   r"   r   r   r   r9   ~   r5   )F)r    )r$   )r'   )r)   )r+   )r2   )r3   )r6   )r7   )r9   )Ú__doc__r-   r   r   r   ZIPythonr   ZIPython.core.errorr   ZIPython.utilsr   r   r    r$   r(   r)   r+   r2   r3   r6   r8   r9   r   r   r   r   Ú<module>   s&    

0







