Sublime Forum

Style the output panel

#1

Hello,

I’d like to know if it’s possible to style the output panel to use the active color scheme style.

My code to create an output panel:

output = window.create_output_panel("variable_get") output.run_command('erase_view') output.run_command('append', {'characters': variable}) window.run_command("show_panel", {"panel": "output.variable_get"})
Currently it shows a white background with black text. If I use the Build system though, the output from a build utilizes the same styles as the current color scheme I have activated - that’s the behavior I’d like to achieve.

Thank you,

Kosta

1 Like

HELP: Output panel as second column layout?
#2
output.set_syntax_file("Packages/Syntax/Syntax.tmLanguage")

with the path obviously adapted to the syntax you want to use.

0 Likes

#3

Thank you for the help. Where can I find “Packages/Syntax/” to access the default syntaxes provided by ST3? I looked in “~/Library/Application Support/Sublime Text 3” but did not find anything there.

0 Likes

#4

sublimetext.com/docs/3/packages.html

You will find zipped “.sublime-package” files there which map to a package respectively.

So, in order to highlight Python code (in “<executable_path>/Packages/Python.sublime-package/Python.tmLanguage”) you have to set the syntax to “Packages/Python/Python.tmLanguage”.

0 Likes

#5

Just in case you don’t feel like extracting the package to see the contents, you could use github.com/skuroda/PackageResourceViewer. Wrote it to save myself the hassle of extracting when I wanted to check something that wasn’t easily accessible via a menu.

1 Like

#6

That’s indeed a nice idea.

Btw, I suggest an on_pre_save handler that creates the dir if the save location set in a specific setting is the same as the view’s file_name(). This would reduce the need of 2 separate commands because now you can just save the file if you want to and it will only then create the dirs automatically (to not make ST spit errors).

Could put this in a github issue though.

0 Likes

#7

@FichteFoll

Thanks so much for your help!

I ended up using output.set_syntax_file("Packages/Text/Plain Text.tmLanguage") and it’s just what I was looking for.

0 Likes

#8

Two more related questions:

Is it possible to set a default height of the output panel (e.g. 40 lines of text?)

Can you apply a word wrap column to the output panel?

0 Likes

#9
  1. No. However, Sublime Text remembers each output panel’s height and will open it with the same size you closed it with.

  2. output.settings().set("rulers", [80])
0 Likes

#10

Thanks for your help. I should have been clearer with regards to #2. I’d like to have the text wrapped at column 80, not just show a ruler. The result I would like to get would be the same as if you had an output panel with text that spanned, say, 120 columns, and you selected all of the text and went to View > Word Wrap Column > 80.

0 Likes

#11

output.set_read_only(False) output.run_command("wrap_lines", {"width": 80}) output.set_read_only(True)

Yeah, you can do pretty much anything you can do with normal views because output panels actually are views.

1 Like

#12

This is awesome. It is a PITA to do this all manually. Plus since the modified file is used by Sublime 3 to override the original package, this is really nifty. Thank you.

0 Likes

#13

Ok, could you help me how to style the build output for dummies. Where do I put output.set_syntax_file(), I can’t find that in the Them files.

0 Likes

#14

You have to be more specific. I’m afraid I have no idea what you want to do.

0 Likes