forked from schinckel/pdbtextmatesupport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PdbTextMateSupport.py
36 lines (30 loc) · 895 Bytes
/
PdbTextMateSupport.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from os.path import exists, realpath
from os import system
OSA_TEMEPLATE = """tell application "System Events"
tell application "TextMate" to get url "%s"
tell process "TextMate"
keystroke tab using {command down}
end tell
end tell"""
have_appscript = False
try:
from appscript import app
have_appscript = True
except:
pass
def mate(self):
frame, lineno = self.stack[self.curindex]
filename = self.canonic(frame.f_code.co_filename)
if exists(filename):
filename = realpath(filename)
tm_url = 'txmt://open?url=file://%s&line=%d&column=2' % (filename, lineno)
if have_appscript:
app("TextMate").get_url(tm_url)
else:
osa_cmd = OSA_TEMEPLATE % tm_url
system('osascript -e \'%s\'' % osa_cmd)
def preloop(self):
mate(self)
def precmd(self, line):
mate(self)
return line