Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ST4] Make editing scheme/theme, OS aware when the corresponding is set to auto. #330

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion plugins/color_scheme_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,33 @@ def run(self):
(setting, self.get_scheme_path(view, setting))
for setting in ('dark_color_scheme', 'light_color_scheme')
]
current_os_mode = sublime.ui_info()['system']['style']
choices = [
sublime.QuickPanelItem(setting, details=str(path), kind=KIND_SCHEME)
for setting, path in paths
]

for idx, choice in enumerate(choices):
if current_os_mode == 'dark' and choice.trigger == 'dark_color_scheme':
choice.annotation = 'Active'
selected_index = idx
elif current_os_mode == 'light' and choice.trigger == 'light_color_scheme':
choice.annotation = 'Active'
selected_index = idx
else:
choice.annotation = ''
selected_index = -1
FichteFoll marked this conversation as resolved.
Show resolved Hide resolved

def on_done(i):
if i >= 0:
self.open_scheme(paths[i][1])

self.window.show_quick_panel(choices, on_done)
self.window.show_quick_panel(
choices,
on_done,
selected_index=selected_index,
placeholder='Choose a color scheme to edit ...'
)

@staticmethod
def get_scheme_path(view, setting_name):
Expand Down
18 changes: 17 additions & 1 deletion plugins/theme_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,28 @@ def run(self):
)
for setting in ('dark_theme', 'light_theme')
]
current_os_mode = sublime.ui_info()['system']['style']
for idx, choice in enumerate(choices):
if current_os_mode == 'dark' and choice.trigger == 'dark_theme':
choice.annotation = 'Active'
selected_index = idx
elif current_os_mode == 'light' and choice.trigger == 'light_theme':
choice.annotation = 'Active'
selected_index = idx
else:
choice.annotation = ''
selected_index = -1

def on_done(i):
if i >= 0:
self.open_theme(choices[i].details)

self.window.show_quick_panel(choices, on_done)
self.window.show_quick_panel(
choices,
on_done,
selected_index=selected_index,
placeholder="Choose a theme to edit ..."
)

def open_theme(self, theme_name):
theme_path = ResourcePath(sublime.find_resources(theme_name)[0])
Expand Down