Sublime Forum

Menu item to activate a mode

#1

I’m completely new to python and ST2, so any help you can offer (and the more specific you can be) I will be incredibly grateful.

I have a pretty complex package idea that would actually involve multiple plugins, and a theme specific to this type of project. However, you would not want all of these plugins active for every project. I’m thinking the best way to handle this would be a user menu item called “activate ### mode.” when this mode is selected, the theme and all of the associated plugins become active. When it is unselected, everything reverts back to your defaults. I’m not sure, but isn’t this how vintage mode works?

Since I’m just getting my feet wet, I’m only trying to create the theme, the menu item and the command to activate/deactivate the theme. I’m hoping that if someone could show me (one time, I promise) how to accomplish this, I would then be able to apply this to the rest of the functionality when the time comes.

Thank you very much for your time.

0 Likes

#2

I’ve played around a little bit, and this is what I have so far. Please let me know if this is correct, or if I need to change something. In the Packages/User directory I have my ActivateMode package folder. Inside this folder, I have three folders: mode_settings, mode_theme, mode_packages. I also have a Main.sublime-menu and ActivateMode.py. Inside the mode_theme folder I have my custom theme, along with a font file. Inside my mode_settings folder I have a Preferences.sublime-settings file with my custom theme and font declared.

The idea is to have the Main.sublime-menu add the command to the tools menu like so:

[code]
{
“id”: “tools”,
“children”:

    {"id": "tools"},  
    { "command": "activate_mode" }  
]  

}
][/code]

Then, have ActivateMode.py create a folder called recover_settings in the Packages/User/ folder and move the Preferences.sublime-settings there. Then, copy the Preferences.sublime-settings located in Packages/User/ActivateMode/mode_settings/ into the Packages/User/ folder. Then, of course, on unselecting the menu item, have all of this reversed so that it returns to the normal settings.

I’ve already performed all of the steps above by hand, and it seems to work pretty well. Now, how would I accomplish this in Python?
Does this sound like I doing this the right way, or am I making it too complex? Thank you.

0 Likes