-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathVisual Studio Code.edit.py
More file actions
89 lines (62 loc) · 2.26 KB
/
Visual Studio Code.edit.py
File metadata and controls
89 lines (62 loc) · 2.26 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import os
import subprocess
import sys
import renpy
class Editor(renpy.editor.Editor):
has_projects = True
def get_code(self):
"""
Returns the path to the code executable.
"""
system = __file__.endswith(" (System).edit.py")
if system:
if "RENPY_VSCODE" in os.environ:
return os.environ["RENPY_VSCODE"]
if renpy.windows:
return "code.cmd"
if renpy.macintosh and os.path.exists("/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"):
return "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"
return "code"
else:
RENPY_VSCODE = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "vscode"))
if renpy.windows:
code = os.path.join(RENPY_VSCODE, "VSCode-win32-x64", "bin", "code.cmd")
elif renpy.macintosh:
code = os.path.join(RENPY_VSCODE, "Visual Studio Code.app", "Contents", "Resources", "app", "bin", "code")
elif renpy.linux:
if renpy.arch == "aarch64":
arch = "arm64"
elif renpy.arch == "armv7l":
arch = "arm"
else:
arch = "x64"
code = os.path.join(RENPY_VSCODE, "VSCode-linux-" + arch, "bin", "code")
else:
code = "code"
return code
def open(self, filename, line=None, **kwargs):
if line:
filename = "{}:{}".format(filename, line)
self.args.append(filename)
def open_project(self, project):
self.args.append(project)
def begin(self, new_window=False, **kwargs):
self.args = [ ]
def end(self, **kwargs):
self.args.reverse()
code = self.get_code()
args = [ code, "-g" ] + self.args
args = [ renpy.exports.fsencode(i) for i in args ]
if renpy.windows:
CREATE_NO_WINDOW = 0x08000000
subprocess.Popen(args, creationflags=CREATE_NO_WINDOW)
else:
subprocess.Popen(args)
def main():
e = Editor()
e.begin()
for i in sys.argv[1:]:
e.open(i)
e.end()
if __name__ == "__main__":
main()