
    ^h                     v    S r SSKrSSKrSSKrSSKJr  / SQrSSSS	.rSS
 jrS r	 " S S5      r
S rS rS rg)a  Hooks for IPython.

In Python, it is possible to overwrite any method of any object if you really
want to.  But IPython exposes a few 'hooks', methods which are *designed* to
be overwritten by users for customization purposes.  This module defines the
default versions of all such hooks, which get used by IPython if not
overridden by the user.

Hooks are simple functions, but they should be declared with ``self`` as their
first argument, because when activated they are registered into IPython as
instance methods. The self argument will be the IPython running instance
itself, so hooks have full access to the entire IPython object.

If you wish to define a new hook and activate it, you can make an :doc:`extension
</config/extensions/index>` or a :ref:`startup script <startup_files>`. For
example, you could use a startup file like this::

    import os

    def calljed(self,filename, linenum):
        "My editor hook calls the jed editor directly."
        print "Calling my own editor, jed ..."
        if os.system('jed +%d %s' % (linenum,filename)) != 0:
            raise TryNext()

    def load_ipython_extension(ip):
        ip.set_hook('editor', calljed)

    N   TryNext)editorsynchronize_with_editorshow_in_pagerpre_prompt_hookclipboard_getz8a callback for the 'pre_execute' or 'pre_run_cell' eventz,a callback for the 'shell_initialized' eventzthe atexit module)pre_run_code_hooklate_startup_hookshutdown_hookc                 L   U R                   nUb  US:X  a  SnOS[        U5      -  nSU;   a2  [        R                  R	                  U5      (       a  US   S:w  a  SU-  n[
        R                  " U< SU< SU< 3S	S
9nU(       a  UR                  5       S:w  a
  [        5       egg)a   Open the default editor at the given filename and linenumber.

This is IPython's default editor hook, you can use it as an example to
write your own modified one.  To set your own editor function as the
new editor hook, call ip.set_hook('editor',yourfunc).Nnotepad z+%d r   "z"%s"T)shell)	r   intospathisfile
subprocessPopenwaitr   )selffilenamelinenumr   r   linemarkprocs          L/home/james-whalen/.local/lib/python3.13/site-packages/IPython/core/hooks.pyr   r   <   s     [[F &)+3w<' f}//F1I4D& &(HE"&(D		q i !t    c                     g N )r   r   r   columns       r    r   r   X   s    r!   c                   >    \ rS rSrSrS
S jrS rS rSS jrS r	S	r
g)CommandChainDispatcher\   zDispatch calls to a chain of commands until some func can handle it

Usage: instantiate, execute "add" to add commands (with optional
priority), execute normally via f() calling mechanism.

Nc                 &    Uc  / U l         g Xl         g r#   chain)r   commandss     r    __init__CommandChainDispatcher.__init__c   s    DJ!Jr!   c                     [        5       nU R                   H  u  pE U" U0 UD6s  $    Ue! [          a  nUn SnAM&  SnAff = f)zCommand chain is called just like normal func.

This will call all funcs in chain with the same args as were given to
this function, and return the result of first func that didn't raise
TryNextN)r   r+   )r   argskwlast_excpriocmdexcs          r    __call__CommandChainDispatcher.__call__j   sN     9

HDD'B'' #   s   +
A=Ac                 ,    [        U R                  5      $ r#   )strr+   r   s    r    __str__CommandChainDispatcher.__str__z   s    4::r!   c                 p    U R                   R                  X!45        U R                   R                  S S9  g)z0Add a func to the cmd chain with given priority c                     U S   $ )Nr   r$   )xs    r    <lambda>,CommandChainDispatcher.add.<locals>.<lambda>   s    adr!   )keyN)r+   appendsort)r   funcprioritys      r    addCommandChainDispatcher.add}   s)    

8*+

N+r!   c                 ,    [        U R                  5      $ )zEReturn all objects in chain.

Handy if the objects are not callable.
)iterr+   r:   s    r    __iter__CommandChainDispatcher.__iter__   s    
 DJJr!   r*   r#   )r   )__name__
__module____qualname____firstlineno____doc__r-   r6   r;   rG   rK   __static_attributes__r$   r!   r    r'   r'   \   s     " ,
 r!   r'   c                     [         e)zRun a string through pager r   )r   datastartscreen_liness       r    r   r      s	     Mr!   c                     g)zRun before displaying the next prompt

Use this e.g. to display output from asynchronous operations (in order
to not mess up text entry)
Nr$   r:   s    r    r	   r	      s     r!   c                     SSK JnJnJnJn  [
        R                  S:X  a  X2/nO[
        R                  S:X  a  X/nOXB/n[        5       nU H  nUR                  U5        M     U" 5       nU$ )z!Get text from the clipboard.
       )osx_clipboard_gettkinter_clipboard_getwin32_clipboard_getwayland_clipboard_getwin32darwin)	lib.clipboardrZ   r[   r\   r]   sysplatformr'   rG   )	r   rZ   r[   r\   r]   r+   
dispatcherrE   texts	            r    r
   r
      sh      ||w$<		!":&>')Jt <DKr!   )NT)rQ   r   r   ra   errorr   __all__
deprecatedr   r   r'   r   r	   r
   r$   r!   r    <module>rh      sW   J 
  
 
 $^#Q2

8+  + \r!   