##// END OF EJS Templates
synchronize with editor patch
synchronize with editor patch

File last commit:

r1242:350716d3
r1242:350716d3
Show More
ip_synchronize_with_gvim.py
28 lines | 827 B | text/x-python | PythonLexer
/ IPython / Extensions / ip_synchronize_with_gvim.py
import IPython.ipapi
ip = IPython.ipapi.get()
import win32api
import win32ui
import win32console
import os
path = r"C:\Program Files\vim\vim71"
def synchronize_with_editor(ip, filename, lineno, columnno):
if not os.path.isabs(filename):
filename = os.path.join(os.getcwd(), filename)
if not os.path.isfile(filename):
print "couldn't find file:", file
return
h = win32console.GetConsoleWindow()
w = win32ui.CreateWindowFromHandle(h)
w.SetWindowText("%s %d" % (filename, lineno))
command = r'start %s --remote-silent +%d "%s"' % (win32api.GetShortPathName(os.path.join(path, "gvim.exe")), lineno, filename)
os.system(command)
win32api.Sleep(500)
w.SetForegroundWindow()
ip.set_hook("synchronize_with_editor", synchronize_with_editor)