diff --git a/tests/cli/test_run.py b/tests/cli/test_run.py index 935a5396b9a..1527a713d9d 100644 --- a/tests/cli/test_run.py +++ b/tests/cli/test_run.py @@ -5,7 +5,6 @@ import pytest from zulipterminal.cli.run import ( - THEMES, _write_zuliprc, exit_with_error, get_login_id, @@ -140,7 +139,6 @@ def test_valid_zuliprc_but_no_connection( def test_warning_regarding_incomplete_theme( capsys, mocker, - monkeypatch, minimal_zuliprc, bad_theme, server_connection_error="sce", @@ -149,13 +147,12 @@ def test_warning_regarding_incomplete_theme( "zulipterminal.core.Controller.__init__", side_effect=ServerConnectionFailure(server_connection_error), ) - - monkeypatch.setitem(THEMES, bad_theme, []) mocker.patch("zulipterminal.cli.run.all_themes", return_value=("a", "b", "c", "d")) mocker.patch( "zulipterminal.cli.run.complete_and_incomplete_themes", return_value=(["a", "b"], ["c", "d"]), ) + mocker.patch("zulipterminal.cli.run.generate_theme") with pytest.raises(SystemExit) as e: main(["-c", minimal_zuliprc, "-t", bad_theme]) diff --git a/tests/config/test_themes.py b/tests/config/test_themes.py index ab3b89447b3..1137da9ac15 100644 --- a/tests/config/test_themes.py +++ b/tests/config/test_themes.py @@ -4,14 +4,11 @@ import pytest from zulipterminal.config.themes import ( - NEW_THEMES, REQUIRED_STYLES, THEMES, all_themes, complete_and_incomplete_themes, - generate_theme, parse_themefile, - theme_with_monochrome_added, ) @@ -20,7 +17,6 @@ "gruvbox_dark", "zt_light", "zt_blue", - "gruvbox_dark24", } aliases_16_color = [ "default", @@ -54,11 +50,11 @@ def test_all_themes(): theme if theme in expected_complete_themes else pytest.param(theme, marks=pytest.mark.xfail(reason="incomplete")) - for theme in NEW_THEMES + for theme in THEMES ], ) -def test_new_builtin_theme_completeness(theme_name): - theme = NEW_THEMES[theme_name] +def test_builtin_theme_completeness(theme_name): + theme = THEMES[theme_name] theme_styles = theme.STYLES theme_colors = theme.Color @@ -91,60 +87,6 @@ def test_new_builtin_theme_completeness(theme_name): assert fg in theme_colors and bg in theme_colors -# Check built-in themes are complete for quality-control purposes -@pytest.mark.parametrize( - "theme_name", - [ - theme - if theme in expected_complete_themes - else pytest.param(theme, marks=pytest.mark.xfail(reason="incomplete")) - for theme in THEMES - ], -) -def test_builtin_theme_completeness(theme_name): - theme = THEMES[theme_name] - styles_in_theme = {style[0] for style in theme} - - assert len(styles_in_theme) == len(REQUIRED_STYLES) - assert all(required_style in styles_in_theme for required_style in REQUIRED_STYLES) - - -@pytest.mark.parametrize( - "theme_name, depth", - [ - ("zt_dark", 1), - ("zt_dark", 16), - ("zt_dark", 256), - ("zt_light", 16), - ("zt_blue", 16), - ("gruvbox_dark", 16), - ("gruvbox_dark", 256), - ("gruvbox_dark24", 2 ** 24), - ("gruvbox_dark24", 2 ** 24), - ], -) -def test_migrated_themes(theme_name, depth): - def split_and_strip(style): - style = style.split(",") - style = [s.strip() for s in style] - return style - - old_theme = theme_with_monochrome_added(THEMES[theme_name]) - - new_theme = generate_theme(theme_name.replace("24", ""), depth) - - for new_style, old_style in zip(new_theme, old_theme): - assert new_style[0] == old_style[0] - if depth == 1: - assert new_style[3] == old_style[3] - elif depth == 16: - assert split_and_strip(new_style[1]) == split_and_strip(old_style[1]) - assert split_and_strip(new_style[2]) == split_and_strip(old_style[2]) - else: - assert split_and_strip(new_style[4]) == split_and_strip(old_style[4]) - assert split_and_strip(new_style[5]) == split_and_strip(old_style[5]) - - def test_complete_and_incomplete_themes(): # These are sorted to ensure reproducibility result = ( diff --git a/zulipterminal/cli/run.py b/zulipterminal/cli/run.py index c43888e5d97..14dccae4f44 100755 --- a/zulipterminal/cli/run.py +++ b/zulipterminal/cli/run.py @@ -12,11 +12,10 @@ from urwid import display_common, set_encoding from zulipterminal.config.themes import ( - THEMES, aliased_themes, all_themes, complete_and_incomplete_themes, - theme_with_monochrome_added, + generate_theme, ) from zulipterminal.core import Controller from zulipterminal.model import ServerConnectionFailure @@ -486,10 +485,7 @@ def main(options: Optional[List[str]] = None) -> None: break boolean_settings[setting] = zterm[setting][0] == valid_values[0] - if color_depth == 1: - theme_data = theme_with_monochrome_added(THEMES[theme_to_use[0]]) - else: - theme_data = THEMES[theme_to_use[0]] + theme_data = generate_theme(theme_to_use[0], color_depth) Controller( zuliprc_path, diff --git a/zulipterminal/config/themes.py b/zulipterminal/config/themes.py index 1bfa33d0f89..1131044c597 100644 --- a/zulipterminal/config/themes.py +++ b/zulipterminal/config/themes.py @@ -69,68 +69,12 @@ } # fmt: on -# 256-color base names for default theme (bold values added below) -DEF_base = dict( - dark_red="#a00", - brown="#880", - dark_blue="#24a", - dark_cyan="#088", - dark_gray="#666", - light_gray="#ccc", - light_red="#f00", - light_green="#0f0", - dark_green="#080", - yellow="#ff0", - light_blue="#28d", - light_magenta="#c8f", - white="#fff", - black="g19", -) - -DEF = dict( - DEF_base, **{f"{color}:bold": f"{code}, bold" for color, code in DEF_base.items()} -) - -# Colors used in gruvbox-256 -# See https://github.com/morhetz/gruvbox/blob/master/colors/gruvbox.vim -BLACK = "h234" # dark0_hard -WHITE = "h250" # light2 -WHITEBOLD = f"{WHITE}, bold" -DARKBLUE = "h24" # faded_blue -DARKRED = "h88" # faded_red -LIGHTBLUE = "h109" # bright_blue -LIGHTBLUEBOLD = f"{LIGHTBLUE}, bold" -YELLOW = "h172" # neutral_yellow -YELLOWBOLD = f"{YELLOW}, bold" -LIGHTGREEN = "h142" # bright_green -LIGHTRED = "h167" # bright_red -LIGHTREDBOLD = f"{LIGHTRED}, bold" -GRAY = "h244" # gray_244 -LIGHTGRAY = "h248" # light3 -LIGHTMAGENTA = "h132" # neutral_purple -LIGHTMAGENTABOLD = f"{LIGHTMAGENTA}, bold" -DARKCYAN = "h66" # neutral_blue -BROWN = "h136" # faded_yellow - -# Colors used in gruvbox_dark24 -BLACK24 = "#1d2021" # dark0_hard -WHITE24 = "#d5c4a1" # light2 -WHITEBOLD24 = f"{WHITE24}, bold" -DARKBLUE24 = "#076678" # faded_blue -DARKRED24 = "#9d0006" # faded_red -LIGHTBLUE24 = "#83a598" # bright_blue -LIGHTBLUEBOLD24 = f"{LIGHTBLUE24}, bold" -YELLOW24 = "#d79921" # neutral_yellow -YELLOWBOLD24 = f"{YELLOW24}, bold" -LIGHTGREEN24 = "#b8bb26" # bright_green -LIGHTRED24 = "#fb4934" # bright_red -LIGHTREDBOLD24 = f"{LIGHTRED24}, bold" -GRAY24 = "#928374" # gray_244 -LIGHTGRAY24 = "#bdae93" # light3 -LIGHTMAGENTA24 = "#b16286" # neutral_purple -LIGHTMAGENTABOLD24 = f"{LIGHTMAGENTA24}, bold" -DARKCYAN24 = "#458588" # neutral_blue -BROWN24 = "#b57614" # faded_yellow +THEMES = { + "gruvbox_dark": gruvbox, + "zt_dark": zt_dark, + "zt_light": zt_light, + "zt_blue": zt_blue, +} THEME_ALIASES = { "default": "zt_dark", @@ -139,425 +83,6 @@ "blue": "zt_blue", } -# fmt: off -THEMES: Dict[str, ThemeSpec] = { - 'zt_dark': [ - (None, 'white', 'black', - None, DEF['white'], DEF['black']), - ('selected', 'white', 'dark blue', - None, DEF['white'], DEF['dark_blue']), - ('msg_selected', 'white', 'dark blue', - None, DEF['white'], DEF['dark_blue']), - ('header', 'dark cyan', 'dark blue', - None, DEF['dark_cyan'], DEF['dark_blue']), - ('general_narrow', 'white', 'dark blue', - None, DEF['white'], DEF['dark_blue']), - ('general_bar', 'white', 'black', - None, DEF['white'], DEF['black']), - ('name', 'yellow, bold', 'black', - None, DEF['yellow:bold'], DEF['black']), - ('unread', 'dark blue', 'black', - None, DEF['dark_blue'], DEF['black']), - ('user_active', 'light green', 'black', - None, DEF['light_green'], DEF['black']), - ('user_idle', 'yellow', 'black', - None, DEF['yellow'], DEF['black']), - ('user_offline', 'white', 'black', - None, DEF['white'], DEF['black']), - ('user_inactive', 'white', 'black', - None, DEF['white'], DEF['black']), - ('title', 'white, bold', 'black', - None, DEF['white:bold'], DEF['black']), - ('column_title', 'white, bold', 'black', - None, DEF['white:bold'], DEF['black']), - ('time', 'light blue', 'black', - None, DEF['light_blue'], DEF['black']), - ('bar', 'white', 'dark gray', - None, DEF['white'], DEF['dark_gray']), - ('popup_contrast', 'white', 'dark gray', - None, DEF['white'], DEF['dark_gray']), - ('msg_emoji', 'light magenta', 'black', - None, DEF['light_magenta'], DEF['black']), - ('reaction', 'light magenta, bold', 'black', - None, DEF['light_magenta:bold'], DEF['black']), - ('reaction_mine', 'black', 'light magenta', - None, DEF['black'], DEF['light_magenta']), - ('msg_mention', 'light red, bold', 'black', - None, DEF['light_red:bold'], DEF['black']), - ('msg_link', 'light blue', 'black', - None, DEF['light_blue'], DEF['black']), - ('msg_link_index', 'light blue, bold', 'black', - None, DEF['light_blue:bold'], DEF['black']), - ('msg_quote', 'brown', 'black', - None, DEF['brown'], DEF['black']), - ('msg_code', 'black', 'white', - None, DEF['black'], DEF['white']), - ('msg_bold', 'white, bold', 'black', - None, DEF['white:bold'], DEF['black']), - ('msg_time', 'black', 'white', - None, DEF['black'], DEF['white']), - ('footer', 'black', 'light gray', - None, DEF['black'], DEF['light_gray']), - ('footer_contrast', 'white', 'black', - None, DEF['white'], DEF['black']), - ('starred', 'light red, bold', 'black', - None, DEF['light_red:bold'], DEF['black']), - ('popup_category', 'light blue, bold', 'black', - None, DEF['light_blue:bold'], DEF['black']), - ('unread_count', 'yellow', 'black', - None, DEF['yellow'], DEF['black']), - ('starred_count', 'light gray', 'black', - None, DEF['light_gray'], DEF['black']), - ('table_head', 'white, bold', 'black', - None, DEF['white:bold'], DEF['black']), - ('filter_results', 'white', 'dark green', - None, DEF['white'], DEF['dark_green']), - ('edit_topic', 'white', 'dark gray', - None, DEF['white'], DEF['dark_gray']), - ('edit_tag', 'white', 'dark gray', - None, DEF['white'], DEF['dark_gray']), - ('edit_author', 'yellow', 'black', - None, DEF['yellow'], DEF['black']), - ('edit_time', 'light blue', 'black', - None, DEF['light_blue'], DEF['black']), - ('current_user', 'white', 'black', - None, DEF['white'], DEF['black']), - ('muted', 'light blue', 'black', - None, DEF['light_blue'], DEF['black']), - ('popup_border', 'white', 'black', - None, DEF['white'], DEF['black']), - ('area:help', 'white', 'dark green', - None, DEF['white'], DEF['dark_green']), - ('area:msg', 'white', 'brown', - None, DEF['white'], DEF['brown']), - ('area:stream', 'white', 'dark cyan', - None, DEF['white'], DEF['dark_cyan']), - ('area:error', 'white', 'dark red', - None, DEF['white'], DEF['dark_red']), - ('search_error', 'light red', 'black', - None, DEF['light_red'], DEF['black']), - ('task:success', 'white', 'dark green', - None, DEF['white'], DEF['dark_green']), - ('task:error', 'white', 'dark red', - None, DEF['white'], DEF['dark_red']), - ('task:warning', 'white', 'brown', - None, DEF['white'], DEF['brown']), - ], - 'gruvbox_dark': [ - # default colorscheme on 16 colors, gruvbox colorscheme - # on 256 colors - (None, 'white', 'black', - None, WHITE, BLACK), - ('selected', 'black', 'white', - None, BLACK, WHITE), - ('msg_selected', 'black', 'white', - None, BLACK, WHITE), - ('header', 'dark cyan', 'dark blue', - None, DARKCYAN, DARKBLUE), - ('general_narrow', 'white', 'dark blue', - None, WHITE, DARKBLUE), - ('general_bar', 'white', 'black', - None, WHITE, BLACK), - ('name', 'yellow, bold', 'black', - None, YELLOWBOLD, BLACK), - ('unread', 'light magenta', 'black', - None, LIGHTMAGENTA, BLACK), - ('user_active', 'light green', 'black', - None, LIGHTGREEN, BLACK), - ('user_idle', 'yellow', 'black', - None, YELLOW, BLACK), - ('user_offline', 'white', 'black', - None, WHITE, BLACK), - ('user_inactive', 'white', 'black', - None, WHITE, BLACK), - ('title', 'white, bold', 'black', - None, WHITEBOLD, BLACK), - ('column_title', 'white, bold', 'black', - None, WHITEBOLD, BLACK), - ('time', 'light blue', 'black', - None, LIGHTBLUE, BLACK), - ('bar', 'white', 'dark gray', - None, WHITE, GRAY), - ('popup_contrast', 'black', 'dark gray', - None, BLACK, GRAY), - ('msg_emoji', 'light magenta', 'black', - None, LIGHTMAGENTA, BLACK), - ('reaction', 'light magenta, bold', 'black', - None, LIGHTMAGENTABOLD, BLACK), - ('reaction_mine', 'black', 'light magenta', - None, BLACK, LIGHTMAGENTA), - ('msg_mention', 'light red, bold', 'black', - None, LIGHTREDBOLD, BLACK), - ('msg_link', 'light blue', 'black', - None, LIGHTBLUE, BLACK), - ('msg_link_index', 'light blue, bold', 'black', - None, LIGHTBLUEBOLD, BLACK), - ('msg_quote', 'brown', 'black', - None, BROWN, BLACK), - ('msg_code', 'black', 'white', - None, BLACK, WHITE), - ('msg_bold', 'white, bold', 'black', - None, WHITEBOLD, BLACK), - ('msg_time', 'black', 'white', - None, BLACK, WHITE), - ('footer', 'black', 'light gray', - None, BLACK, LIGHTGRAY), - ('footer_contrast', 'white', 'black', - None, WHITE, BLACK), - ('starred', 'light red, bold', 'black', - None, LIGHTREDBOLD, BLACK), - ('popup_category', 'light blue, bold', 'black', - None, LIGHTBLUEBOLD, BLACK), - ('unread_count', 'yellow', 'black', - None, YELLOW, BLACK), - ('starred_count', 'light gray', 'black', - None, LIGHTGRAY, BLACK), - ('table_head', 'white, bold', 'black', - None, WHITEBOLD, BLACK), - ('filter_results', 'black', 'light green', - None, BLACK, LIGHTGREEN), - ('edit_topic', 'black', 'dark gray', - None, BLACK, GRAY), - ('edit_tag', 'black', 'dark gray', - None, BLACK, GRAY), - ('edit_author', 'yellow', 'black', - None, YELLOW, BLACK), - ('edit_time', 'light blue', 'black', - None, LIGHTBLUE, BLACK), - ('current_user', 'white', 'black', - None, WHITE, BLACK), - ('muted', 'light blue', 'black', - None, LIGHTBLUE, BLACK), - ('popup_border', 'white', 'black', - None, WHITE, BLACK), - ('area:help', 'black', 'light green', - None, BLACK, LIGHTGREEN), - ('area:msg', 'black', 'light red', - None, BLACK, LIGHTRED), - ('area:stream', 'black', 'light blue', - None, BLACK, LIGHTBLUE), - ('area:error', 'white', 'dark red', - None, WHITE, DARKRED), - ('search_error', 'light red', 'black', - None, LIGHTRED, BLACK), - ('task:success', 'black', 'light green', - None, BLACK, LIGHTGREEN), - ('task:error', 'white', 'dark red', - None, WHITE, DARKRED), - ('task:warning', 'black', 'light red', - None, BLACK, LIGHTRED), - ], - 'gruvbox_dark24': [ - # default colorscheme on 16 colors, gruvbox colorscheme - # on 24 bit color (true color) - (None, 'white', 'black', - None, WHITE24, BLACK24), - ('selected', 'black', 'white', - None, BLACK24, WHITE24), - ('msg_selected', 'black', 'white', - None, BLACK24, WHITE24), - ('header', 'dark cyan', 'dark blue', - None, DARKCYAN24, DARKBLUE24), - ('general_narrow', 'white', 'dark blue', - None, WHITE24, DARKBLUE24), - ('general_bar', 'white', 'black', - None, WHITE24, BLACK24), - ('name', 'yellow, bold', 'black', - None, YELLOWBOLD24, BLACK24), - ('unread', 'light magenta', 'black', - None, LIGHTMAGENTA24, BLACK24), - ('user_active', 'light green', 'black', - None, LIGHTGREEN24, BLACK24), - ('user_idle', 'yellow', 'black', - None, YELLOW24, BLACK24), - ('user_offline', 'white', 'black', - None, WHITE24, BLACK24), - ('user_inactive', 'white', 'black', - None, WHITE24, BLACK24), - ('title', 'white, bold', 'black', - None, WHITEBOLD24, BLACK24), - ('column_title', 'white, bold', 'black', - None, WHITEBOLD24, BLACK24), - ('time', 'light blue', 'black', - None, LIGHTBLUE24, BLACK24), - ('bar', 'white', 'dark gray', - None, WHITE24, GRAY24), - ('popup_contrast', 'black', 'dark gray', - None, BLACK24, GRAY24), - ('msg_emoji', 'light magenta', 'black', - None, LIGHTMAGENTA24, BLACK24), - ('reaction', 'light magenta, bold', 'black', - None, LIGHTMAGENTABOLD24, BLACK24), - ('reaction_mine', 'black', 'light magenta', - None, BLACK24, LIGHTMAGENTA24), - ('msg_mention', 'light red, bold', 'black', - None, LIGHTREDBOLD24, BLACK24), - ('msg_link', 'light blue', 'black', - None, LIGHTBLUE24, BLACK24), - ('msg_link_index', 'light blue, bold', 'black', - None, LIGHTBLUEBOLD24, BLACK24), - ('msg_quote', 'brown', 'black', - None, BROWN24, BLACK24), - ('msg_code', 'black', 'white', - None, BLACK24, WHITE24), - ('msg_bold', 'white, bold', 'black', - None, WHITEBOLD24, BLACK24), - ('msg_time', 'black', 'white', - None, BLACK24, WHITE24), - ('footer', 'black', 'light gray', - None, BLACK24, LIGHTGRAY24), - ('footer_contrast', 'white', 'black', - None, WHITE24, BLACK24), - ('starred', 'light red, bold', 'black', - None, LIGHTREDBOLD24, BLACK24), - ('popup_category', 'light blue, bold', 'black', - None, LIGHTBLUEBOLD24, BLACK24), - ('unread_count', 'yellow', 'black', - None, YELLOW24, BLACK24), - ('starred_count', 'light gray', 'black', - None, LIGHTGRAY24, BLACK24), - ('table_head', 'white, bold', 'black', - None, WHITEBOLD24, BLACK24), - ('filter_results', 'black', 'light green', - None, BLACK24, LIGHTGREEN24), - ('edit_topic', 'black', 'dark gray', - None, BLACK24, GRAY24), - ('edit_tag', 'black', 'dark gray', - None, BLACK24, GRAY24), - ('edit_author', 'yellow', 'black', - None, YELLOW24, BLACK24), - ('edit_time', 'light blue', 'black', - None, LIGHTBLUE24, BLACK24), - ('current_user', 'white', 'black', - None, WHITE24, BLACK24), - ('muted', 'light blue', 'black', - None, LIGHTBLUE24, BLACK24), - ('popup_border', 'white', 'black', - None, WHITE24, BLACK24), - ('area:help', 'black', 'light green', - None, BLACK24, LIGHTGREEN24), - ('area:msg', 'black', 'light red', - None, BLACK24, LIGHTRED24), - ('area:stream', 'black', 'light blue', - None, BLACK24, LIGHTBLUE24), - ('area:error', 'white', 'dark red', - None, WHITE24, DARKRED24), - ('search_error', 'light red', 'black', - None, LIGHTRED24, BLACK24), - ('task:success', 'black', 'light green', - None, BLACK24, LIGHTGREEN24), - ('task:error', 'white', 'dark red', - None, WHITE24, DARKRED24), - ('task:warning', 'black', 'light red', - None, BLACK24, LIGHTRED24), - ], - 'zt_light': [ - (None, 'black', 'white'), - ('selected', 'black', 'light green'), - ('msg_selected', 'black', 'light green'), - ('header', 'white', 'dark blue'), - ('general_narrow', 'white', 'dark blue'), - ('general_bar', 'dark blue', 'white'), - ('name', 'dark green', 'white'), - ('unread', 'dark gray', 'light gray'), - ('user_active', 'dark green', 'white'), - ('user_idle', 'dark blue', 'white'), - ('user_offline', 'black', 'white'), - ('user_inactive', 'black', 'white'), - ('title', 'white, bold', 'dark gray'), - ('column_title', 'black, bold', 'white'), - ('time', 'dark blue', 'white'), - ('bar', 'white', 'dark gray'), - ('popup_contrast', 'white', 'dark gray'), - ('msg_emoji', 'light magenta', 'white'), - ('reaction', 'light magenta, bold', 'white'), - ('reaction_mine', 'white', 'light magenta'), - ('msg_mention', 'light red, bold', 'white'), - ('msg_link', 'dark blue', 'white'), - ('msg_link_index', 'dark blue, bold', 'white'), - ('msg_quote', 'black', 'brown'), - ('msg_code', 'black', 'light gray'), - ('msg_bold', 'white, bold', 'dark gray'), - ('msg_time', 'white', 'dark gray'), - ('footer', 'white', 'dark gray'), - ('footer_contrast', 'black', 'white'), - ('starred', 'light red, bold', 'white'), - ('popup_category', 'dark gray, bold', 'light gray'), - ('unread_count', 'dark blue, bold', 'white'), - ('starred_count', 'black', 'white'), - ('table_head', 'black, bold', 'white'), - ('filter_results', 'white', 'dark green'), - ('edit_topic', 'white', 'dark gray'), - ('edit_tag', 'white', 'dark gray'), - ('edit_author', 'dark green', 'white'), - ('edit_time', 'dark blue', 'white'), - ('current_user', 'dark gray', 'white'), - ('muted', 'dark gray', 'white'), - ('popup_border', 'black', 'white'), - ('area:help', 'black', 'light green'), - ('area:stream', 'black', 'light blue'), - ('area:msg', 'black', 'yellow'), - ('area:error', 'black', 'light red'), - ('search_error', 'light red', 'white'), - ('task:success', 'black', 'dark green'), - ('task:error', 'white', 'dark red'), - ('task:warning', 'black', 'yellow'), - ], - 'zt_blue': [ - (None, 'black', 'light blue'), - ('selected', 'black', 'light gray'), - ('msg_selected', 'black', 'light gray'), - ('header', 'black', 'dark blue'), - ('general_narrow', 'white', 'dark blue'), - ('general_bar', 'dark blue', 'light blue'), - ('name', 'dark red', 'light blue'), - ('unread', 'light gray', 'light blue'), - ('user_active', 'light green, bold', 'light blue'), - ('user_idle', 'dark gray', 'light blue'), - ('user_offline', 'black', 'light blue'), - ('user_inactive', 'black', 'light blue'), - ('title', 'white, bold', 'dark blue'), - ('column_title', 'black, bold', 'light blue'), - ('time', 'dark blue', 'light blue'), - ('bar', 'white', 'dark blue'), - ('popup_contrast', 'white', 'dark blue'), - ('msg_emoji', 'dark magenta', 'light blue'), - ('reaction', 'dark magenta, bold', 'light blue'), - ('reaction_mine', 'light blue', 'dark magenta'), - ('msg_mention', 'light red, bold', 'light blue'), - ('msg_link', 'dark blue', 'light gray'), - ('msg_link_index', 'dark blue, bold', 'light gray'), - ('msg_quote', 'brown', 'dark blue'), - ('msg_code', 'dark blue', 'white'), - ('msg_bold', 'white, bold', 'dark blue'), - ('msg_time', 'dark blue', 'white'), - ('footer', 'white', 'dark gray'), - ('footer_contrast', 'black', 'white'), - ('starred', 'light red, bold', 'light blue'), - ('popup_category', 'light gray, bold', 'light blue'), - ('unread_count', 'yellow', 'light blue'), - ('starred_count', 'black', 'light blue'), - ('table_head', 'black, bold', 'light blue'), - ('filter_results', 'white', 'dark green'), - ('edit_topic', 'white', 'dark blue'), - ('edit_tag', 'white', 'dark blue'), - ('edit_author', 'dark gray', 'light blue'), - ('edit_time', 'dark blue', 'light blue'), - ('current_user', 'light gray', 'light blue'), - ('muted', 'light gray', 'light blue'), - ('popup_border', 'white', 'light blue'), - ('area:help', 'white', 'dark green'), - ('area:stream', 'white', 'dark cyan'), - ('area:msg', 'white', 'brown'), - ('area:error', 'white', 'dark red'), - ('search_error', 'light red', 'light blue'), - ('task:success', 'white', 'dark green'), - ('task:error', 'white', 'dark red'), - ('task:warning', 'white', 'brown'), - ] -} -# fmt: on - def all_themes() -> List[str]: return list(THEMES.keys()) @@ -570,42 +95,15 @@ def aliased_themes() -> Dict[str, str]: def complete_and_incomplete_themes() -> Tuple[List[str], List[str]]: complete = { name - for name, styles in THEMES.items() - if {s[0] for s in styles} == set(REQUIRED_STYLES) + for name, theme in THEMES.items() + if set(theme.STYLES) == set(REQUIRED_STYLES) } incomplete = list(set(THEMES) - complete) return sorted(list(complete)), sorted(incomplete) -def theme_with_monochrome_added(theme: ThemeSpec) -> Any: - updated_theme = [] - for style in theme: - style_name = style[0] - if style_name not in REQUIRED_STYLES: - continue - mono_style = REQUIRED_STYLES[style_name] - if len(style) > 4: # 256 colors+ - new_style = style[:3] + (mono_style,) + style[4:] - elif len(style) == 4: # 16 colors + mono (overwrite mono) - new_style = style[:3] + (mono_style,) - elif len(style) == 3: # 16 colors only - new_style = style[:3] + (mono_style,) - else: # 1-to-1 mapping (same as other style) - new_style = style - updated_theme.append(new_style) - return updated_theme - - -NEW_THEMES = { - "gruvbox_dark": gruvbox, - "zt_dark": zt_dark, - "zt_light": zt_light, - "zt_blue": zt_blue, -} - - def generate_theme(theme_name: str, color_depth: int) -> ThemeSpec: - theme_styles = NEW_THEMES[theme_name].STYLES + theme_styles = THEMES[theme_name].STYLES urwid_theme = parse_themefile(theme_styles, color_depth) return urwid_theme