o
    Ďi                     @   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    S/home/jeff/fluffinator/venv/lib/python3.10/site-packages/IPython/lib/editorhooks.pycall_editor.   s   

z#install_editor.<locals>.call_editoreditorN)r   )r   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dirname__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   r4   g   s   emacsc                 C      t | d  d S )Nr+   r"   r#   r   r   r   r5   r      	gnuclientc                 C   r6   )Nz -nw +{line} {filename}r"   r#   r   r   r   r8   v   r7   cedt.exec                 C   r6   )Nz /L:{line} {filename}r"   r#   r   r   r   crimson_editorz   r7   r:   katec                 C   r6   )Nz -u -l {line} {filename}r"   r#   r   r   r   r;   ~   r7   )F)r!   )r%   )r(   )r*   )r,   )r4   )r5   )r8   )r9   )r;   )__doc__r.   r   r   r   IPythonr   IPython.core.errorr   IPython.utilsr   r    r!   r%   r)   r*   r,   r4   r5   r8   r:   r;   r   r   r   r   <module>   s&    

0







