Home Download Buy Blog Forum Support

Set theme/color scheme in memory

Set theme/color scheme in memory

Postby damccull on Wed Mar 05, 2014 12:02 am

Is there a way to set the global theme and color scheme in memory, without having to make changes to the preferences file? In other words, an API call on the window to set them. If not, can one be added to an upcoming version of ST? My plugin Solarized Toggle could greatly benefit from this behavior.
damccull
 
Posts: 5
Joined: Sun Jul 14, 2013 7:48 pm

Re: Set theme/color scheme in memory

Postby jbjornson on Wed Mar 05, 2014 8:37 am

For a temporary (view specific) change:

Code: Select all
view.settings().set('color_scheme', 'Packages/Color Scheme - Default/Solarized (Light).tmTheme')


...and for a global change:

Code: Select all
sublime.load_settings('Preferences.sublime-settings').set('color_scheme', 'Packages/Color Scheme - Default/Solarized (Light).tmTheme')
jbjornson
 
Posts: 353
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland

Re: Set theme/color scheme in memory

Postby FichteFoll on Tue Mar 11, 2014 3:40 am

Don't forget `sublime.save_settings('Preferences.sublime-settings')` even though I'm not particularly sure if it's actually necessary. You should test it.
FichteFoll
 
Posts: 408
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: Set theme/color scheme in memory

Postby jbjornson on Tue Mar 11, 2014 8:37 am

True, but you only need to save the settings if you want the changes to be persisted. The change in settings is immediately effective, regardless if you save them or not.
jbjornson
 
Posts: 353
Joined: Tue Oct 27, 2009 4:25 pm
Location: Zurich, Switzerland


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 8 guests