##// END OF EJS Templates
ipy_editors.py: Add 'wait' for nonblocking editors like komodo
vivainio -
Show More
@@ -1,31 +1,43 b''
1 """ 'editor' hooks for common editors that work well with ipython
1 """ 'editor' hooks for common editors that work well with ipython
2
2
3 They should honor the line number argument, at least.
3 They should honor the line number argument, at least.
4
4
5 Contributions are *very* welcome.
5 Contributions are *very* welcome.
6 """
6 """
7
7
8 import IPython.ipapi
8 import IPython.ipapi
9 ip = IPython.ipapi.get()
9 ip = IPython.ipapi.get()
10
10
11 from IPython.Itpl import itplns
11 from IPython.Itpl import itplns
12 import os
12 import os
13
13
14 def install_editor(run_template):
14 def install_editor(run_template, wait = False):
15 """ Gets a template in format "myeditor bah bah $file bah bah $line
16
17 Installs the editor that is called by IPython, instead of the default
18 notepad or vi.
19 """
20
15 def call_editor(self, file, line):
21 def call_editor(self, file, line):
16 if line is None:
22 if line is None:
17 line = 0
23 line = 0
18 cmd = itplns(run_template, locals())
24 cmd = itplns(run_template, locals())
19 print ">",cmd
25 print ">",cmd
20 os.system(cmd)
26 os.system(cmd)
27 if wait:
28 raw_input("Press Enter when done editing:")
21
29
22 ip.set_hook('editor',call_editor)
30 ip.set_hook('editor',call_editor)
23
31
24 def komodo(exe = 'komodo'):
32 def komodo(exe = 'komodo'):
25 """ Warning - komodo does not block """
33 """ Activestate Komodo [Edit]
26 install_editor(exe + ' -l $line "$file"')
34
35 Warning - komodo does not block, so can't be used for plain %edit
36
37 """
38 install_editor(exe + ' -l $line "$file"', wait = True)
27
39
28 def scite(exe = "scite"):
40 def scite(exe = "scite"):
29 """ Exe is the executable name of your scite.
41 """ Exe is the executable name of your scite.
30 """
42 """
31 install_editor(exe + ' "$file" -goto:$line') No newline at end of file
43 install_editor(exe + ' "$file" -goto:$line')
General Comments 0
You need to be logged in to leave comments. Login now