Remove the monochrome palette

Monochrome colors should be defined as the third color in each tuple
instead.

In monochrome mode it's not possible to set the background so all
highlights can only be done using bold, italics, underline...
This commit is contained in:
Ivan Habunek 2023-07-08 12:30:49 +02:00
parent 0c0f889e3f
commit afd349f1ab
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D
3 changed files with 22 additions and 75 deletions

View File

@ -1,15 +0,0 @@
from toot.tui.constants import PALETTE, MONO_PALETTE
def test_palette():
# for every entry in PALETTE, there must be
# a corresponding entry in MONO_PALETTE
for pal in PALETTE:
matches = [item for item in MONO_PALETTE if item[0] == pal[0]]
assert len(matches) > 0, f"{pal}, present in PALETTE, missing from MONO_PALETTE"
# for every entry in MONO_PALETTE, there must be
# a corresponding entry in PALETTE
for pal in MONO_PALETTE:
matches = [item for item in PALETTE if item[0] == pal[0]]
assert len(matches) > 0, f"{pal}, present in MONO_PALETTE, missing from PALETTE"

View File

@ -8,7 +8,7 @@ from toot.console import get_default_visibility
from toot.exceptions import ApiError
from .compose import StatusComposer
from .constants import PALETTE, MONO_PALETTE
from .constants import PALETTE
from .entities import Status
from .overlays import ExceptionStackTrace, GotoMenu, Help, StatusSource, StatusLinks, StatusZoom
from .overlays import StatusDeleteConfirmation, Account
@ -84,7 +84,7 @@ class TUI(urwid.Frame):
screen = TUI.create_screen(args)
tui = TUI(app, user, screen, args)
palette = MONO_PALETTE if args.no_color else PALETTE
palette = PALETTE.copy()
overrides = settings.get_setting("tui.palette", dict, {})
for name, styles in overrides.items():
palette.append(tuple([name] + styles))

View File

@ -1,8 +1,19 @@
# name, fg, bg, mono, fg_h, bg_h
# Color definitions are tuples of:
# - name
# - foreground (normal mode)
# - background (normal mode)
# - foreground (monochrome mode)
# - foreground (high color mode)
# - background (high color mode)
#
# See:
# http://urwid.org/tutorial/index.html#display-attributes
# http://urwid.org/manual/displayattributes.html#using-display-attributes
PALETTE = [
# Components
('button', 'white', 'black'),
('button_focused', 'light gray', 'dark magenta'),
('button_focused', 'light gray', 'dark magenta', 'bold,underline'),
('card_author', 'yellow', ''),
('card_title', 'dark green', ''),
('columns_divider', 'white', 'dark blue'),
@ -14,7 +25,7 @@ PALETTE = [
('footer_status', 'white', 'dark blue'),
('footer_status_bold', 'white, bold', 'dark blue'),
('header', 'white', 'dark blue'),
('header_bold', 'white,bold', 'dark blue'),
('header_bold', 'white,bold', 'dark blue', 'bold'),
('intro_bigtext', 'yellow', ''),
('intro_smalltext', 'light blue', ''),
('poll_bar', 'white', 'dark blue'),
@ -22,17 +33,17 @@ PALETTE = [
('status_detail_bookmarked', 'light red', ''),
('status_detail_timestamp', 'light blue', ''),
('status_list_account', 'dark green', ''),
('status_list_selected', 'white,bold', 'dark green'),
('status_list_selected', 'white,bold', 'dark green', 'bold,underline'),
('status_list_timestamp', 'light blue', ''),
# Functional
('account', 'dark green', ''),
('hashtag', 'light cyan,bold', ''),
('hashtag_followed', 'yellow,bold', ''),
('link', ',italics', ''),
('link_focused', ',italics', 'dark magenta'),
('hashtag', 'light cyan,bold', '', 'bold'),
('hashtag_followed', 'yellow,bold', '', 'bold'),
('link', ',italics', '', ',italics'),
('link_focused', ',italics', 'dark magenta', "underline,italics"),
('shortcut', 'light blue', ''),
('shortcut_highlight', 'white,bold', ''),
('shortcut_highlight', 'white,bold', '', 'bold'),
('warning', 'light red', ''),
# Visiblity
@ -48,55 +59,6 @@ PALETTE = [
('success', 'dark green', ''),
]
MONO_PALETTE = [
# Components
('button', 'white', 'black'),
('button_focused', 'black', 'white'),
('card_author', 'white', ''),
('card_title', 'white, bold', ''),
('columns_divider', 'white', 'black'),
('content_warning', 'white', 'black'),
('editbox', 'white', 'black'),
('editbox_focused', 'black', 'white'),
('footer_message', 'white', 'black'),
('footer_message_error', 'white,bold', 'black'),
('footer_status', 'black', 'white'),
('footer_status_bold', 'black,bold', 'white'),
('header', 'black', 'white'),
('header_bold', 'black,bold', 'white'),
('intro_bigtext', 'white', 'black'),
('intro_smalltext', 'white', 'black'),
('poll_bar', 'black', 'white'),
('status_detail_account', 'white', ''),
('status_detail_bookmarked', 'white', ''),
('status_detail_timestamp', 'white', ''),
('status_list_account', 'white', ''),
('status_list_selected', 'white,bold', ''),
('status_list_timestamp', 'white', ''),
('warning', 'white,bold', 'black'),
# Functional
('account', 'white', ''),
('hashtag_followed', 'white,bold', ''),
('hashtag', 'white,bold', ''),
('link', ',italics', ''),
('link_focused', ',bold,italics', ''),
('shortcut', 'white', ''),
('shortcut_highlight', 'white,bold', ''),
# Visiblity
('visibility_public', 'white', ''),
('visibility_unlisted', 'white', ''),
('visibility_private', 'white', ''),
('visibility_direct', 'white', ''),
# Styles
('bold', ',bold', ''),
('dim', 'light gray', ''),
('highlight', ',bold', ''),
('success', '', ''),
]
VISIBILITY_OPTIONS = [
("public", "Public", "Post to public timelines"),
("unlisted", "Unlisted", "Do not post to public timelines"),