Permalink
Browse files

contextual menus

  • Loading branch information...
ostinelli committed Apr 15, 2012
1 parent 2067738 commit db8ec6c4b3fa7941daa2bc436dde7c867e1abc3a
Showing with 35 additions and 4 deletions.
  1. +13 −0 Context.sublime-menu
  2. +22 −4 sublimerl.py
View
@@ -0,0 +1,13 @@
+[
+ { "caption": "-" },
+ {
+ "caption": "SublimErl",
+ "children":
+ [
+ { "caption": "Run Contextual Test", "command": "sublim_erl_test" },
+ { "caption": "Run Dialyzer", "command": "sublim_erl_dialyzer" },
+ { "caption": "Run Last Run test", "command": "sublim_erl_test_redo" },
+ { "caption": "View CT results", "command": "sublim_erl_ct_results" }
+ ]
+ }
+]
View
@@ -460,8 +460,20 @@ def interpret_dialyzer_test_results(self, retcode, data):
+# common text command class
+class SublimErlTextCommand(sublime_plugin.TextCommand):
+
+ def is_enabled(self):
+ view = sublime.active_window().active_view()
+ if view:
+ if view.settings().get('syntax') == 'Packages/Erlang/Erlang.tmLanguage':
+ return self.show_contextual_menu()
+
+ def show_contextual_menu(self):
+ return True
+
# start new test
-class SublimErlTestCommand(sublime_plugin.TextCommand):
+class SublimErlTestCommand(SublimErlTextCommand):
def run(self, edit):
# init
test_runner = SublimErlTestRunner(self.view)
@@ -470,7 +482,7 @@ def run(self, edit):
test_runner.start_test()
# start new test
-class SublimErlDialyzerCommand(sublime_plugin.TextCommand):
+class SublimErlDialyzerCommand(SublimErlTextCommand):
def run(self, edit):
# init
test_runner = SublimErlTestRunner(self.view)
@@ -479,16 +491,19 @@ def run(self, edit):
test_runner.start_test(dialyzer=True)
# repeat last test
-class SublimErlTestRedoCommand(sublime_plugin.TextCommand):
+class SublimErlTestRedoCommand(SublimErlTextCommand):
def run(self, edit):
# init
test_runner = SublimErlTestRunner(self.view, new=False)
if test_runner.available == False: return
# run tests
test_runner.start_test()
+ def show_contextual_menu(self):
+ return SUBLIMERL_LAST_TEST != None
+
# open CT results
-class SublimErlCtResultsCommand(sublime_plugin.TextCommand):
+class SublimErlCtResultsCommand(SublimErlTextCommand):
def run(self, edit):
# init
launcher = SublimErlLauncher(self.view, show_log=False, new=False)
@@ -497,6 +512,9 @@ def run(self, edit):
index_path = os.path.abspath(os.path.join('logs', 'index.html'))
if os.path.exists(index_path): webbrowser.open(index_path)
+ def show_contextual_menu(self):
+ return SUBLIMERL_LAST_ROOT != None
+
# listener on save
class SublimErlListener(sublime_plugin.EventListener):
def on_post_save(self, view):

0 comments on commit db8ec6c

Please sign in to comment.