Sublime Forum

Styling output.exec panel

#1

I have a plugin that executes a command via a shell call.

I would like to style the output.

I’ve seen you can do it from a ruby plugin I’ve seen but I’m completely baffled by thTheme & tmLanguage files even though everyone seems to suggest they are easy.

The output I have is:

xUnit.net console test runner (32-bit .NET 4.0.30319.17020)
Copyright (C) 2015 Outercurve Foundation.

Discovering: Owin.StatelessAuth.Tests
Discovered:  Owin.StatelessAuth.Tests
Starting:    Owin.StatelessAuth.Tests
Finished:    Owin.StatelessAuth.Tests

=== TEST EXECUTION SUMMARY ===
   Owin.StatelessAuth.Tests  Total: 17, Errors: 0, Failed: 0, Skipped: 0, Time: 0.231s
[Finished in 1.4s]

I’ve got as far as getting the regex for the output I’m interested in:

^\s+\S+ Total: \d+, Errors: \d+, Failed: \d+, Skipped: \d+, Time: \d+.\d+s$

I have a thTheme and tmLanguage files borrowed from https://github.com/maltize/sublime-text-2-ruby-tests that I’ve tried to modify but I never seem to get colours applied in the output.exec panel so wondering if starting from scratch would be better. I want the total to be green, errors to be red, failed to be red and skipped to be yellow and time to be blue.

I was wondering if someone could help.

0 Likes

#2

If your syntax def is valid, you can use the ‘syntax’ argument to the exec command in order to use a specific syntax definition:

[code]class ExecCommand(sublime_plugin.WindowCommand, ProcessListener):
BLOCK_SIZE = 2**14
text_queue = collections.deque()
text_queue_proc = None
text_queue_lock = threading.Lock()

proc = None

def run(self, cmd = None, shell_cmd = None, file_regex = "", line_regex = "", working_dir = "",
        encoding = "utf-8", env = {}, quiet = False, kill = False,
        word_wrap = True, syntax = "Packages/Text/Plain text.tmLanguage",
        # Catches "path" and "shell"
        **kwargs):

…[/code]

But that’s only if you are using ST’s built-in commands to display output from external processes.

More info on syntax defs:

docs.sublimetext.info/en/latest/ … xdefs.html

You may point us to some code to see what’s wrong/missing. Output panels can mostly be treated as plain views, so configuring the syntax def and color scheme works the same way in both.

0 Likes

#3

I have the syntax argument working and being applied to the panel its just not styling the test results. I kept the tmTheme the same as shown in earlier link and have tried all sorts in the tmLanguage.

I thought this might at least style the line with the results but its just white on black;

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>bundleUUID</key>
  <string>72174d10-bb12-11e0-962b-112233445566</string>
  <key>name</key>
  <string>TestConsole</string>
  <key>patterns</key>
  <array>
    <dict>
      <key>name</key>
      <string>test.pass</string>
      <key>match</key>
      <string>^\s+\S+  Total: \d+, Errors: \d+, Failed: \d+, Skipped: \d+, Time: \d+.\d+s$</string>
    </dict>
  </array>
  <key>scopeName</key>
  <string>tests.ruby</string>
  <key>uuid</key>
  <string>72174d10-bb12-11e0-962b-112233445566</string>
</dict>
</plist>
0 Likes