Remove named colours
This is a prerequisite for configurable styling, since we don't want to override "green" style to be yellow and such.
This commit is contained in:
parent
9933180146
commit
219225ba8a
5 changed files with 91 additions and 71 deletions
|
@ -66,8 +66,8 @@ class StatusComposer(urwid.Frame):
|
||||||
|
|
||||||
def generate_list_items(self):
|
def generate_list_items(self):
|
||||||
if self.in_reply_to:
|
if self.in_reply_to:
|
||||||
yield urwid.Text(("gray", "Replying to {}".format(self.in_reply_to.original.account)))
|
yield urwid.Text(("dim", "Replying to {}".format(self.in_reply_to.original.account)))
|
||||||
yield urwid.AttrWrap(urwid.Divider("-"), "gray")
|
yield urwid.AttrWrap(urwid.Divider("-"), "dim")
|
||||||
|
|
||||||
yield urwid.Text("Status message")
|
yield urwid.Text("Status message")
|
||||||
yield self.content_edit
|
yield self.content_edit
|
||||||
|
|
|
@ -3,6 +3,8 @@ PALETTE = [
|
||||||
# Components
|
# Components
|
||||||
('button', 'white', 'black'),
|
('button', 'white', 'black'),
|
||||||
('button_focused', 'light gray', 'dark magenta'),
|
('button_focused', 'light gray', 'dark magenta'),
|
||||||
|
('card_author', 'yellow', ''),
|
||||||
|
('card_title', 'dark green', ''),
|
||||||
('columns_divider', 'white', 'dark blue'),
|
('columns_divider', 'white', 'dark blue'),
|
||||||
('content_warning', 'white', 'dark magenta'),
|
('content_warning', 'white', 'dark magenta'),
|
||||||
('editbox', 'white', 'black'),
|
('editbox', 'white', 'black'),
|
||||||
|
@ -16,7 +18,12 @@ PALETTE = [
|
||||||
('intro_bigtext', 'yellow', ''),
|
('intro_bigtext', 'yellow', ''),
|
||||||
('intro_smalltext', 'light blue', ''),
|
('intro_smalltext', 'light blue', ''),
|
||||||
('poll_bar', 'white', 'dark blue'),
|
('poll_bar', 'white', 'dark blue'),
|
||||||
|
('status_detail_account', 'dark green', ''),
|
||||||
|
('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'),
|
||||||
|
('status_list_timestamp', 'light blue', ''),
|
||||||
|
|
||||||
# Functional
|
# Functional
|
||||||
('hashtag', 'light cyan,bold', ''),
|
('hashtag', 'light cyan,bold', ''),
|
||||||
|
@ -27,20 +34,25 @@ PALETTE = [
|
||||||
('shortcut_highlight', 'white,bold', ''),
|
('shortcut_highlight', 'white,bold', ''),
|
||||||
('warning', 'light red', ''),
|
('warning', 'light red', ''),
|
||||||
|
|
||||||
# Colors
|
# Visiblity
|
||||||
|
('visibility_public', 'dark gray', ''),
|
||||||
|
('visibility_unlisted', 'white', ''),
|
||||||
|
('visibility_private', 'dark cyan', ''),
|
||||||
|
('visibility_direct', 'yellow', ''),
|
||||||
|
|
||||||
|
# Styles
|
||||||
('bold', ',bold', ''),
|
('bold', ',bold', ''),
|
||||||
('blue', 'light blue', ''),
|
('dim', 'dark gray', ''),
|
||||||
('cyan', 'dark cyan', ''),
|
('highlight', 'yellow', ''),
|
||||||
('gray', 'dark gray', ''),
|
('success', 'dark green', ''),
|
||||||
('green', 'dark green', ''),
|
|
||||||
('yellow', 'yellow', ''),
|
|
||||||
('red', 'dark red', ''),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
MONO_PALETTE = [
|
MONO_PALETTE = [
|
||||||
# Components
|
# Components
|
||||||
('button', 'white', 'black'),
|
('button', 'white', 'black'),
|
||||||
('button_focused', 'black', 'white'),
|
('button_focused', 'black', 'white'),
|
||||||
|
('card_author', 'white', ''),
|
||||||
|
('card_title', 'white, bold', ''),
|
||||||
('columns_divider', 'white', 'black'),
|
('columns_divider', 'white', 'black'),
|
||||||
('content_warning', 'white', 'black'),
|
('content_warning', 'white', 'black'),
|
||||||
('editbox', 'white', 'black'),
|
('editbox', 'white', 'black'),
|
||||||
|
@ -54,25 +66,34 @@ MONO_PALETTE = [
|
||||||
('intro_bigtext', 'white', 'black'),
|
('intro_bigtext', 'white', 'black'),
|
||||||
('intro_smalltext', 'white', 'black'),
|
('intro_smalltext', 'white', 'black'),
|
||||||
('poll_bar', 'black', 'white'),
|
('poll_bar', 'black', 'white'),
|
||||||
('status_list_selected', '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
|
# Functional
|
||||||
('hashtag_followed', 'white,bold', 'black'),
|
('account', 'dark green', ''),
|
||||||
('hashtag', 'white,bold', 'black'),
|
('hashtag_followed', 'white,bold', ''),
|
||||||
('link', ',italics', 'black'),
|
('hashtag', 'white,bold', ''),
|
||||||
('link_focused', ',bold,italics', 'black'),
|
('link', ',italics', ''),
|
||||||
|
('link_focused', ',bold,italics', ''),
|
||||||
('shortcut', 'white', ''),
|
('shortcut', 'white', ''),
|
||||||
('shortcut_highlight', 'white,bold', ''),
|
('shortcut_highlight', 'white,bold', ''),
|
||||||
|
|
||||||
# Colors
|
# Visiblity
|
||||||
('bold', ',bold', 'black'),
|
('visibility_public', 'white', ''),
|
||||||
('blue', 'white', 'black'),
|
('visibility_unlisted', 'white', ''),
|
||||||
('cyan', 'white', 'black'),
|
('visibility_private', 'white', ''),
|
||||||
('gray', 'white', 'black'),
|
('visibility_direct', 'white', ''),
|
||||||
('green', 'white', 'black'),
|
|
||||||
('yellow', 'white', 'black'),
|
# Styles
|
||||||
('red', 'white', 'black'),
|
('bold', ',bold', ''),
|
||||||
('warning', 'white,bold', 'black'),
|
('dim', 'light gray', ''),
|
||||||
|
('highlight', ',bold', ''),
|
||||||
|
('success', '', ''),
|
||||||
]
|
]
|
||||||
|
|
||||||
VISIBILITY_OPTIONS = [
|
VISIBILITY_OPTIONS = [
|
||||||
|
|
|
@ -196,7 +196,7 @@ class Help(urwid.Padding):
|
||||||
|
|
||||||
def generate_contents(self):
|
def generate_contents(self):
|
||||||
def h(text):
|
def h(text):
|
||||||
return highlight_keys(text, "cyan")
|
return highlight_keys(text, "shortcut")
|
||||||
|
|
||||||
yield urwid.Text(("bold", "toot {}".format(__version__)))
|
yield urwid.Text(("bold", "toot {}".format(__version__)))
|
||||||
yield urwid.Divider()
|
yield urwid.Divider()
|
||||||
|
@ -260,10 +260,10 @@ class Account(urwid.ListBox):
|
||||||
yield Button("Cancel", on_press=cancel_action, user_data=self)
|
yield Button("Cancel", on_press=cancel_action, user_data=self)
|
||||||
else:
|
else:
|
||||||
if self.user.username == account["acct"]:
|
if self.user.username == account["acct"]:
|
||||||
yield urwid.Text(("light gray", "This is your account"))
|
yield urwid.Text(("dim", "This is your account"))
|
||||||
else:
|
else:
|
||||||
if relationship['requested']:
|
if relationship['requested']:
|
||||||
yield urwid.Text(("light gray", "< Follow request is pending >"))
|
yield urwid.Text(("dim", "< Follow request is pending >"))
|
||||||
else:
|
else:
|
||||||
yield Button("Unfollow" if relationship['following'] else "Follow",
|
yield Button("Unfollow" if relationship['following'] else "Follow",
|
||||||
on_press=confirm_action, user_data=self)
|
on_press=confirm_action, user_data=self)
|
||||||
|
@ -275,7 +275,7 @@ class Account(urwid.ListBox):
|
||||||
|
|
||||||
yield urwid.Divider("─")
|
yield urwid.Divider("─")
|
||||||
yield urwid.Divider()
|
yield urwid.Divider()
|
||||||
yield urwid.Text([('green', f"@{account['acct']}"), f" {account['display_name']}"])
|
yield urwid.Text([("account", f"@{account['acct']}"), f" {account['display_name']}"])
|
||||||
|
|
||||||
if account["note"]:
|
if account["note"]:
|
||||||
yield urwid.Divider()
|
yield urwid.Divider()
|
||||||
|
@ -283,12 +283,12 @@ class Account(urwid.ListBox):
|
||||||
yield urwid.Text(highlight_hashtags(line, followed_tags=set()))
|
yield urwid.Text(highlight_hashtags(line, followed_tags=set()))
|
||||||
|
|
||||||
yield urwid.Divider()
|
yield urwid.Divider()
|
||||||
yield urwid.Text(["ID: ", ("green", f"{account['id']}")])
|
yield urwid.Text(["ID: ", ("highlight", f"{account['id']}")])
|
||||||
yield urwid.Text(["Since: ", ("green", f"{account['created_at'][:10]}")])
|
yield urwid.Text(["Since: ", ("highlight", f"{account['created_at'][:10]}")])
|
||||||
yield urwid.Divider()
|
yield urwid.Divider()
|
||||||
|
|
||||||
if account["bot"]:
|
if account["bot"]:
|
||||||
yield urwid.Text([("green", "Bot \N{robot face}")])
|
yield urwid.Text([("highlight", "Bot \N{robot face}")])
|
||||||
yield urwid.Divider()
|
yield urwid.Divider()
|
||||||
if account["locked"]:
|
if account["locked"]:
|
||||||
yield urwid.Text([("warning", "Locked \N{lock}")])
|
yield urwid.Text([("warning", "Locked \N{lock}")])
|
||||||
|
@ -297,25 +297,25 @@ class Account(urwid.ListBox):
|
||||||
yield urwid.Text([("warning", "Suspended \N{cross mark}")])
|
yield urwid.Text([("warning", "Suspended \N{cross mark}")])
|
||||||
yield urwid.Divider()
|
yield urwid.Divider()
|
||||||
if relationship["followed_by"]:
|
if relationship["followed_by"]:
|
||||||
yield urwid.Text(("green", "Follows you \N{busts in silhouette}"))
|
yield urwid.Text(("highlight", "Follows you \N{busts in silhouette}"))
|
||||||
yield urwid.Divider()
|
yield urwid.Divider()
|
||||||
if relationship["blocked_by"]:
|
if relationship["blocked_by"]:
|
||||||
yield urwid.Text(("warning", "Blocks you \N{no entry}"))
|
yield urwid.Text(("warning", "Blocks you \N{no entry}"))
|
||||||
yield urwid.Divider()
|
yield urwid.Divider()
|
||||||
|
|
||||||
yield urwid.Text(["Followers: ", ("yellow", f"{account['followers_count']}")])
|
yield urwid.Text(["Followers: ", ("highlight", f"{account['followers_count']}")])
|
||||||
yield urwid.Text(["Following: ", ("yellow", f"{account['following_count']}")])
|
yield urwid.Text(["Following: ", ("highlight", f"{account['following_count']}")])
|
||||||
yield urwid.Text(["Statuses: ", ("yellow", f"{account['statuses_count']}")])
|
yield urwid.Text(["Statuses: ", ("highlight", f"{account['statuses_count']}")])
|
||||||
|
|
||||||
if account["fields"]:
|
if account["fields"]:
|
||||||
for field in account["fields"]:
|
for field in account["fields"]:
|
||||||
name = field["name"].title()
|
name = field["name"].title()
|
||||||
yield urwid.Divider()
|
yield urwid.Divider()
|
||||||
yield urwid.Text([("yellow", f"{name.rstrip(':')}"), ":"])
|
yield urwid.Text([("bold", f"{name.rstrip(':')}"), ":"])
|
||||||
for line in format_content(field["value"]):
|
for line in format_content(field["value"]):
|
||||||
yield urwid.Text(highlight_hashtags(line, followed_tags=set()))
|
yield urwid.Text(highlight_hashtags(line, followed_tags=set()))
|
||||||
if field["verified_at"]:
|
if field["verified_at"]:
|
||||||
yield urwid.Text(("green", "✓ Verified"))
|
yield urwid.Text(("success", "✓ Verified"))
|
||||||
|
|
||||||
yield urwid.Divider()
|
yield urwid.Divider()
|
||||||
yield link("", account["url"])
|
yield link("", account["url"])
|
||||||
|
|
|
@ -61,7 +61,7 @@ class Poll(urwid.ListBox):
|
||||||
|
|
||||||
if poll["voted"] or poll["expired"]:
|
if poll["voted"] or poll["expired"]:
|
||||||
prefix = " ✓ " if voted_for else " "
|
prefix = " ✓ " if voted_for else " "
|
||||||
yield urwid.Text(("gray", prefix + f'{option["title"]}'))
|
yield urwid.Text(("dim", prefix + f'{option["title"]}'))
|
||||||
else:
|
else:
|
||||||
if poll["multiple"]:
|
if poll["multiple"]:
|
||||||
checkbox = CheckBox(f'{option["title"]}')
|
checkbox = CheckBox(f'{option["title"]}')
|
||||||
|
@ -83,7 +83,7 @@ class Poll(urwid.ListBox):
|
||||||
)
|
)
|
||||||
poll_detail += " · Closes on {}".format(expires_at)
|
poll_detail += " · Closes on {}".format(expires_at)
|
||||||
|
|
||||||
yield urwid.Text(("gray", poll_detail))
|
yield urwid.Text(("dim", poll_detail))
|
||||||
|
|
||||||
def generate_contents(self, status):
|
def generate_contents(self, status):
|
||||||
yield urwid.Divider()
|
yield urwid.Divider()
|
||||||
|
|
|
@ -84,11 +84,10 @@ class Timeline(urwid.Columns):
|
||||||
urwid.connect_signal(item, "click", lambda *args:
|
urwid.connect_signal(item, "click", lambda *args:
|
||||||
self.tui.show_context_menu(status))
|
self.tui.show_context_menu(status))
|
||||||
return urwid.AttrMap(item, None, focus_map={
|
return urwid.AttrMap(item, None, focus_map={
|
||||||
"blue": "status_list_selected",
|
"status_list_account": "status_list_selected",
|
||||||
"green": "status_list_selected",
|
"status_list_timestamp": "status_list_selected",
|
||||||
"yellow": "status_list_selected",
|
"highligh": "status_list_selected",
|
||||||
"cyan": "status_list_selected",
|
"dim": "status_list_selected",
|
||||||
"red": "status_list_selected",
|
|
||||||
None: "status_list_selected",
|
None: "status_list_selected",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -323,13 +322,13 @@ class StatusDetails(urwid.Pile):
|
||||||
def content_generator(self, status, reblogged_by):
|
def content_generator(self, status, reblogged_by):
|
||||||
if reblogged_by:
|
if reblogged_by:
|
||||||
text = "♺ {} boosted".format(reblogged_by.display_name or reblogged_by.username)
|
text = "♺ {} boosted".format(reblogged_by.display_name or reblogged_by.username)
|
||||||
yield ("pack", urwid.Text(("gray", text)))
|
yield ("pack", urwid.Text(("dim", text)))
|
||||||
yield ("pack", urwid.AttrMap(urwid.Divider("-"), "gray"))
|
yield ("pack", urwid.AttrMap(urwid.Divider("-"), "dim"))
|
||||||
|
|
||||||
if status.author.display_name:
|
if status.author.display_name:
|
||||||
yield ("pack", urwid.Text(("green", status.author.display_name)))
|
yield ("pack", urwid.Text(("status_detail_author", status.author.display_name)))
|
||||||
|
|
||||||
account_color = "yellow" if status.author.account in self.followed_accounts else "gray"
|
account_color = "highlight" if status.author.account in self.followed_accounts else "dim"
|
||||||
yield ("pack", urwid.Text((account_color, status.author.account)))
|
yield ("pack", urwid.Text((account_color, status.author.account)))
|
||||||
yield ("pack", urwid.Divider())
|
yield ("pack", urwid.Divider())
|
||||||
|
|
||||||
|
@ -348,7 +347,7 @@ class StatusDetails(urwid.Pile):
|
||||||
media = status.data["media_attachments"]
|
media = status.data["media_attachments"]
|
||||||
if media:
|
if media:
|
||||||
for m in media:
|
for m in media:
|
||||||
yield ("pack", urwid.AttrMap(urwid.Divider("-"), "gray"))
|
yield ("pack", urwid.AttrMap(urwid.Divider("-"), "dim"))
|
||||||
yield ("pack", urwid.Text([("bold", "Media attachment"), " (", m["type"], ")"]))
|
yield ("pack", urwid.Text([("bold", "Media attachment"), " (", m["type"], ")"]))
|
||||||
if m["description"]:
|
if m["description"]:
|
||||||
yield ("pack", urwid.Text(m["description"]))
|
yield ("pack", urwid.Text(m["description"]))
|
||||||
|
@ -367,7 +366,7 @@ class StatusDetails(urwid.Pile):
|
||||||
application = status.data.get("application") or {}
|
application = status.data.get("application") or {}
|
||||||
application = application.get("name")
|
application = application.get("name")
|
||||||
|
|
||||||
yield ("pack", urwid.AttrWrap(urwid.Divider("-"), "gray"))
|
yield ("pack", urwid.AttrWrap(urwid.Divider("-"), "dim"))
|
||||||
|
|
||||||
translated_from = (
|
translated_from = (
|
||||||
language_name(status.original.translated_from)
|
language_name(status.original.translated_from)
|
||||||
|
@ -376,24 +375,24 @@ class StatusDetails(urwid.Pile):
|
||||||
)
|
)
|
||||||
|
|
||||||
visibility_colors = {
|
visibility_colors = {
|
||||||
"public": "gray",
|
"public": "visibility_public",
|
||||||
"unlisted": "white",
|
"unlisted": "visibility_unlisted",
|
||||||
"private": "cyan",
|
"private": "visibility_private",
|
||||||
"direct": "yellow"
|
"direct": "visibility_direct"
|
||||||
}
|
}
|
||||||
|
|
||||||
visibility = status.visibility.title()
|
visibility = status.visibility.title()
|
||||||
visibility_color = visibility_colors.get(status.visibility, "gray")
|
visibility_color = visibility_colors.get(status.visibility, "dim")
|
||||||
|
|
||||||
yield ("pack", urwid.Text([
|
yield ("pack", urwid.Text([
|
||||||
("blue", f"{status.created_at.strftime('%Y-%m-%d %H:%M')} "),
|
("status_detail_timestamp", f"{status.created_at.strftime('%Y-%m-%d %H:%M')} "),
|
||||||
("red" if status.bookmarked else "gray", "b "),
|
("status_detail_bookmarked" if status.bookmarked else "dim", "b "),
|
||||||
("gray", f"⤶ {status.data['replies_count']} "),
|
("dim", f"⤶ {status.data['replies_count']} "),
|
||||||
("yellow" if status.reblogged else "gray", f"♺ {status.data['reblogs_count']} "),
|
("highlight" if status.reblogged else "dim", f"♺ {status.data['reblogs_count']} "),
|
||||||
("yellow" if status.favourited else "gray", f"★ {status.data['favourites_count']}"),
|
("highlight" if status.favourited else "dim", f"★ {status.data['favourites_count']}"),
|
||||||
(visibility_color, f" · {visibility}"),
|
(visibility_color, f" · {visibility}"),
|
||||||
("yellow", f" · Translated from {translated_from} " if translated_from else ""),
|
("highlight", f" · Translated from {translated_from} " if translated_from else ""),
|
||||||
("gray", f" · {application}" if application else ""),
|
("dim", f" · {application}" if application else ""),
|
||||||
]))
|
]))
|
||||||
|
|
||||||
# Push things to bottom
|
# Push things to bottom
|
||||||
|
@ -405,9 +404,9 @@ class StatusDetails(urwid.Pile):
|
||||||
return urwid.LineBox(contents)
|
return urwid.LineBox(contents)
|
||||||
|
|
||||||
def card_generator(self, card):
|
def card_generator(self, card):
|
||||||
yield urwid.Text(("green", card["title"].strip()))
|
yield urwid.Text(("card_title", card["title"].strip()))
|
||||||
if card.get("author_name"):
|
if card.get("author_name"):
|
||||||
yield urwid.Text(["by ", ("yellow", card["author_name"].strip())])
|
yield urwid.Text(["by ", ("card_author", card["author_name"].strip())])
|
||||||
yield urwid.Text("")
|
yield urwid.Text("")
|
||||||
if card["description"]:
|
if card["description"]:
|
||||||
yield urwid.Text(card["description"].strip())
|
yield urwid.Text(card["description"].strip())
|
||||||
|
@ -436,7 +435,7 @@ class StatusDetails(urwid.Pile):
|
||||||
expires_at = parse_datetime(poll["expires_at"]).strftime("%Y-%m-%d %H:%M")
|
expires_at = parse_datetime(poll["expires_at"]).strftime("%Y-%m-%d %H:%M")
|
||||||
status += " · Closes on {}".format(expires_at)
|
status += " · Closes on {}".format(expires_at)
|
||||||
|
|
||||||
yield urwid.Text(("gray", status))
|
yield urwid.Text(("dim", status))
|
||||||
|
|
||||||
|
|
||||||
class StatusListItem(SelectableColumns):
|
class StatusListItem(SelectableColumns):
|
||||||
|
@ -452,20 +451,20 @@ class StatusListItem(SelectableColumns):
|
||||||
)
|
)
|
||||||
|
|
||||||
edited_flag = "*" if edited_at else " "
|
edited_flag = "*" if edited_at else " "
|
||||||
favourited = ("yellow", "★") if status.original.favourited else " "
|
favourited = ("highlight", "★") if status.original.favourited else " "
|
||||||
reblogged = ("yellow", "♺") if status.original.reblogged else " "
|
reblogged = ("highlight", "♺") if status.original.reblogged else " "
|
||||||
is_reblog = ("cyan", "♺") if status.reblog else " "
|
is_reblog = ("dim", "♺") if status.reblog else " "
|
||||||
is_reply = ("cyan", "⤶") if status.original.in_reply_to else " "
|
is_reply = ("dim", "⤶") if status.original.in_reply_to else " "
|
||||||
|
|
||||||
return super().__init__([
|
return super().__init__([
|
||||||
("pack", SelectableText(("blue", created_at), wrap="clip")),
|
("pack", SelectableText(("status_list_timestamp", created_at), wrap="clip")),
|
||||||
("pack", urwid.Text(("blue", edited_flag))),
|
("pack", urwid.Text(("status_list_timestamp", edited_flag))),
|
||||||
("pack", urwid.Text(" ")),
|
("pack", urwid.Text(" ")),
|
||||||
("pack", urwid.Text(favourited)),
|
("pack", urwid.Text(favourited)),
|
||||||
("pack", urwid.Text(" ")),
|
("pack", urwid.Text(" ")),
|
||||||
("pack", urwid.Text(reblogged)),
|
("pack", urwid.Text(reblogged)),
|
||||||
("pack", urwid.Text(" ")),
|
("pack", urwid.Text(" ")),
|
||||||
urwid.Text(("green", status.original.account), wrap="clip"),
|
urwid.Text(("status_list_account", status.original.account), wrap="clip"),
|
||||||
("pack", urwid.Text(is_reply)),
|
("pack", urwid.Text(is_reply)),
|
||||||
("pack", urwid.Text(is_reblog)),
|
("pack", urwid.Text(is_reblog)),
|
||||||
("pack", urwid.Text(" ")),
|
("pack", urwid.Text(" ")),
|
||||||
|
|
Loading…
Reference in a new issue