##// END OF EJS Templates
Notification + tooltip demo...
Notification + tooltip demo Use notification to quicky remind use of the tooltip Use javascript in notebook to make a live demo in 01_notebook_introduction tooltip docstring is remplaceid for the first use by a live tutorial

File last commit:

r6624:9d90e074
r7185:a5bcda20
Show More
ipy_editors.py
91 lines | 2.5 KiB | text/x-python | PythonLexer
vivainio
crlf normalization
r851 """ 'editor' hooks for common editors that work well with ipython
They should honor the line number argument, at least.
Contributions are *very* welcome.
"""
Brian Granger
ipapi.py => core/ipapi.py and imports updated.
r2027 from IPython.core import ipapi
Brian Granger
Continuing a massive refactor of everything.
r2205 from IPython.core.error import TryNext
Brian Granger
ipapi.py => core/ipapi.py and imports updated.
r2027 ip = ipapi.get()
vivainio
crlf normalization
r851
Thomas Kluyver
Remove bundled Itpl module.
r6624 # We no longer bundle Itpl. If you update this module, you should use advanced
# string formatting instead.
Brian Granger
Moved Itpl.py to deathrow as we already have a copy in external.
r2031 from IPython.external.Itpl import itplns
vivainio
crlf normalization
r851 import os
def install_editor(run_template, wait = False):
""" Gets a template in format "myeditor bah bah $file bah bah $line"
$file will be replaced by file name, $line by line number (or 0).
Installs the editor that is called by IPython, instead of the default
notepad or vi.
If wait is true, wait until the user presses enter before returning,
to facilitate non-blocking editors that exit immediately after
the call.
"""
vivainio
default line is zero in call_editor!
r853 def call_editor(self, file, line=0):
vivainio
crlf normalization
r851 if line is None:
line = 0
cmd = itplns(run_template, locals())
print ">",cmd
Ville M. Vainio
TryNext editor if editor hook fails. Patch by Lukasz Pankowski
r1744 if os.system(cmd) != 0:
Brian Granger
Continuing a massive refactor of everything.
r2205 raise TryNext()
vivainio
crlf normalization
r851 if wait:
raw_input("Press Enter when done editing:")
ip.set_hook('editor',call_editor)
# in these, exe is always the path/name of the executable. Useful
# if you don't have the editor directory in your path
def komodo(exe = 'komodo'):
""" Activestate Komodo [Edit] """
install_editor(exe + ' -l $line "$file"', wait = True)
def scite(exe = "scite"):
""" SciTE or Sc1 """
install_editor(exe + ' "$file" -goto:$line')
def notepadplusplus(exe = 'notepad++'):
""" Notepad++ http://notepad-plus.sourceforge.net """
install_editor(exe + ' -n$line "$file"')
def jed(exe = 'jed'):
""" JED, the lightweight emacsish editor """
install_editor(exe + ' +$line "$file"')
def idle(exe = None):
""" Idle, the editor bundled with python
Should be pretty smart about finding the executable.
"""
if exe is None:
import idlelib
p = os.path.dirname(idlelib.__file__)
exe = p + '/idle.py'
install_editor(exe + ' "$file"')
Brian Granger
Adding TextMate to ipy_editor.py thanks to Matt Foster for the patch.
r1782
def mate(exe = 'mate'):
""" TextMate, the missing editor"""
install_editor(exe + ' -w -l $line "$file"')
vivainio
crlf normalization
r851
# these are untested, report any problems
def emacs(exe = 'emacs'):
install_editor(exe + ' +$line "$file"')
def gnuclient(exe= 'gnuclient'):
install_editor(exe + ' -nw +$line "$file"')
def crimson_editor(exe = 'cedt.exe'):
vivainio
ipy_editor.kate()
r881 install_editor(exe + ' /L:$line "$file"')
def kate(exe = 'kate'):
install_editor(exe + ' -u -l $line "$file"')
vivainio
crlf normalization
r851
Thomas Kluyver
Remove bundled Itpl module.
r6624