From 40b24f30f7723abdf91a1bf0fbe3236f8638f6ee Mon Sep 17 00:00:00 2001 From: Ashwin Shenoy Date: Sun, 31 Jan 2021 11:47:58 +0530 Subject: [PATCH 1/4] Make color scheme editing, OS mode aware when color_scheme is set to auto. This commit makes editing color schemes, OS mode aware when the color_scheme setting is set to the auto mode. --- plugins/color_scheme_dev.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/color_scheme_dev.py b/plugins/color_scheme_dev.py index b0a45cef..aab0313e 100644 --- a/plugins/color_scheme_dev.py +++ b/plugins/color_scheme_dev.py @@ -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 + 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): From 117c27aabeb7ae8187411385e2be0b5e1269d9d1 Mon Sep 17 00:00:00 2001 From: Ashwin Shenoy Date: Sun, 31 Jan 2021 11:52:30 +0530 Subject: [PATCH 2/4] Make theme editing, OS mode aware when theme is set to auto. This commit makes editing theme, OS mode aware when the theme setting is set to the auto mode. --- plugins/theme_dev.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/theme_dev.py b/plugins/theme_dev.py index d20ca67d..40b93f37 100644 --- a/plugins/theme_dev.py +++ b/plugins/theme_dev.py @@ -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]) From d1e0297239742c81ba949eea35324289a719acbc Mon Sep 17 00:00:00 2001 From: Ashwin Shenoy Date: Sun, 31 Jan 2021 13:41:41 +0530 Subject: [PATCH 3/4] chore: Address some flake8 issues. --- plugins/color_scheme_dev.py | 6 +++--- plugins/theme_dev.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/color_scheme_dev.py b/plugins/color_scheme_dev.py index aab0313e..20c7b837 100644 --- a/plugins/color_scheme_dev.py +++ b/plugins/color_scheme_dev.py @@ -278,10 +278,10 @@ def on_done(i): self.open_scheme(paths[i][1]) self.window.show_quick_panel( - choices, + choices, on_done, - selected_index = selected_index, - placeholder = 'Choose a color scheme to edit ...' + selected_index=selected_index, + placeholder='Choose a color scheme to edit ...' ) @staticmethod diff --git a/plugins/theme_dev.py b/plugins/theme_dev.py index 40b93f37..94c465e8 100644 --- a/plugins/theme_dev.py +++ b/plugins/theme_dev.py @@ -67,10 +67,10 @@ def on_done(i): self.open_theme(choices[i].details) self.window.show_quick_panel( - choices, + choices, on_done, - selected_index = selected_index, - placeholder = "Choose a theme to edit ..." + selected_index=selected_index, + placeholder="Choose a theme to edit ..." ) def open_theme(self, theme_name): From fbd59a5f0709a9b47f3bba9b204765c1bae0558c Mon Sep 17 00:00:00 2001 From: Ashwin Shenoy Date: Sun, 31 Jan 2021 21:52:19 +0530 Subject: [PATCH 4/4] Chore: Address issues raised in review comments (Part 1) --- plugins/color_scheme_dev.py | 9 ++------- plugins/theme_dev.py | 10 +++------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/plugins/color_scheme_dev.py b/plugins/color_scheme_dev.py index 20c7b837..2acbfa03 100644 --- a/plugins/color_scheme_dev.py +++ b/plugins/color_scheme_dev.py @@ -262,16 +262,11 @@ def run(self): for setting, path in paths ] + selected_index = -1 for idx, choice in enumerate(choices): - if current_os_mode == 'dark' and choice.trigger == 'dark_color_scheme': + if choice.trigger.startswith(current_os_mode): 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 def on_done(i): if i >= 0: diff --git a/plugins/theme_dev.py b/plugins/theme_dev.py index 94c465e8..a8fe311e 100644 --- a/plugins/theme_dev.py +++ b/plugins/theme_dev.py @@ -50,17 +50,13 @@ def run(self): ) for setting in ('dark_theme', 'light_theme') ] + current_os_mode = sublime.ui_info()['system']['style'] + selected_index = -1 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': + if choice.trigger.startswith(current_os_mode): choice.annotation = 'Active' selected_index = idx - else: - choice.annotation = '' - selected_index = -1 def on_done(i): if i >= 0: