-
Notifications
You must be signed in to change notification settings - Fork 7
/
new_from_template.py
36 lines (29 loc) · 1.5 KB
/
new_from_template.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
import sublime, sublime_plugin, os
class NetlinxTemplate:
def load_template(self, edit, filename):
# Read in the template.
content = sublime.load_resource("Packages/NetLinx/templates/%(filename)s" % locals()) \
.replace("\r", "")
# Fill a view (tab) with the template text.
# Will fill the current view if it's empty, otherwise a new view
# is created. This is to support right clicking the side bar to
# create a new file in a specific folder.
v = self.view.window().new_file() if self.view.size() > 0 else self.view
v.insert(edit, 0, content)
v.set_syntax_file('Packages/NetLinx/NetLinx.tmLanguage')
# NetLinx Standard Template
class NetlinxNewFromTemplateStandard(sublime_plugin.TextCommand, NetlinxTemplate):
def run(self, edit):
self.load_template(edit, 'Netlinx Standard.axs')
# NetLinx Test Suite Template
class NetlinxNewFromTemplateTestSuite(sublime_plugin.TextCommand, NetlinxTemplate):
def run(self, edit):
self.load_template(edit, 'Netlinx Test Suite.axs')
# NetLinx Include (.axi) Template
class NetlinxNewFromTemplateInclude(sublime_plugin.TextCommand, NetlinxTemplate):
def run(self, edit):
self.load_template(edit, 'Netlinx Include.axs')
# NetLinx Overview Template
class NetlinxNewFromTemplateOverview(sublime_plugin.TextCommand, NetlinxTemplate):
def run(self, edit):
self.load_template(edit, 'Netlinx Overview.axs')