Home Download Buy Blog Forum Support

Style the output panel

Style the output panel

Postby kostajh on Thu Jun 06, 2013 7:12 pm

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:
Code: Select all
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
kostajh
 
Posts: 6
Joined: Thu Jun 06, 2013 7:08 pm

Re: Style the output panel

Postby FichteFoll on Thu Jun 06, 2013 9:45 pm

Code: Select all
output.set_syntax_file("Packages/Syntax/Syntax.tmLanguage")


with the path obviously adapted to the syntax you want to use.
FichteFoll
 
Posts: 400
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: Style the output panel

Postby kostajh on Mon Jun 10, 2013 5:18 pm

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.
kostajh
 
Posts: 6
Joined: Thu Jun 06, 2013 7:08 pm

Re: Style the output panel

Postby FichteFoll on Mon Jun 10, 2013 7:14 pm

https://www.sublimetext.com/docs/3/packages.html

In general, "<executable_path>/Packages" is for packages that ship with Sublime Text, and "<data_path>/Installed Packages" is for packages installed by the user.


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".
FichteFoll
 
Posts: 400
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: Style the output panel

Postby skuroda on Mon Jun 10, 2013 11:45 pm

Just in case you don't feel like extracting the package to see the contents, you could use https://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.
skuroda
 
Posts: 685
Joined: Fri Oct 05, 2012 8:11 am

Re: Style the output panel

Postby FichteFoll on Tue Jun 11, 2013 12:32 am

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.
FichteFoll
 
Posts: 400
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: Style the output panel

Postby kostajh on Tue Jun 11, 2013 2:51 pm

@FichteFoll

Thanks so much for your help!

I ended up using
Code: Select all
output.set_syntax_file("Packages/Text/Plain Text.tmLanguage")
and it's just what I was looking for.
kostajh
 
Posts: 6
Joined: Thu Jun 06, 2013 7:08 pm

Re: Style the output panel

Postby kostajh on Fri Jun 14, 2013 4:58 pm

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?
[
kostajh
 
Posts: 6
Joined: Thu Jun 06, 2013 7:08 pm

Re: Style the output panel

Postby FichteFoll on Fri Jun 14, 2013 5:33 pm

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

2.
Code: Select all
output.settings().set("rulers", [80])
FichteFoll
 
Posts: 400
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: Style the output panel

Postby kostajh on Fri Jun 14, 2013 7:10 pm

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.
kostajh
 
Posts: 6
Joined: Thu Jun 06, 2013 7:08 pm

Next

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 2 guests