sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
807 stars 39 forks source link

Trigger an event when the color_schema/theme is changed #5213

Open timfjord opened 2 years ago

timfjord commented 2 years ago

Problem description

ST 4 introduces "theme": "auto" and "color_scheme": "auto" settings but there is no way to get when the actual change happens. So, say, if there is a plugin with a custom theme, there is no other than a manual way to somehow reflect the color scheme/theme change

Preferred solution

Add sublime_plugin.EventListener.on_style_change(or whatever) event and trigger it when the color_schema/theme is changed Theoretically, the first parameter could be whatever sublime.ui_info returns but it is not critical

class StyleListener(sublime_plugin.EventListener):
    def on_style_change(self, ui_info):
        print(f"Current style is: {ui_info['theme']['style']}")

Alternatives

Theoretically, we could watch when the sublime.ui_info['theme']['style']}" value changes but I would consider it more as a workaround

Additional Information

No response

absop commented 2 years ago

Currently, we can use sublime.Settings.add_on_change() to add a callback to do some checking.

timfjord commented 2 years ago

It is a different concept. Is it for the cases when theme and/or color_scheme are set to auto and Sublime rotates the values based on the system settings.