mirror of
https://github.com/ihabunek/toot
synced 2025-01-10 16:52:40 +01:00
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
@ -66,8 +66,8 @@ class StatusComposer(urwid.Frame):
|
||||
|
||||
def generate_list_items(self):
|
||||
if self.in_reply_to:
|
||||
yield urwid.Text(("gray", "Replying to {}".format(self.in_reply_to.original.account)))
|
||||
yield urwid.AttrWrap(urwid.Divider("-"), "gray")
|
||||
yield urwid.Text(("dim", "Replying to {}".format(self.in_reply_to.original.account)))
|
||||
yield urwid.AttrWrap(urwid.Divider("-"), "dim")
|
||||
|
||||
yield urwid.Text("Status message")
|
||||
yield self.content_edit
|
||||
|
@ -3,6 +3,8 @@ PALETTE = [
|
||||
# Components
|
||||
('button', 'white', 'black'),
|
||||
('button_focused', 'light gray', 'dark magenta'),
|
||||
('card_author', 'yellow', ''),
|
||||
('card_title', 'dark green', ''),
|
||||
('columns_divider', 'white', 'dark blue'),
|
||||
('content_warning', 'white', 'dark magenta'),
|
||||
('editbox', 'white', 'black'),
|
||||
@ -16,7 +18,12 @@ PALETTE = [
|
||||
('intro_bigtext', 'yellow', ''),
|
||||
('intro_smalltext', 'light 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_timestamp', 'light blue', ''),
|
||||
|
||||
# Functional
|
||||
('hashtag', 'light cyan,bold', ''),
|
||||
@ -27,20 +34,25 @@ PALETTE = [
|
||||
('shortcut_highlight', 'white,bold', ''),
|
||||
('warning', 'light red', ''),
|
||||
|
||||
# Colors
|
||||
# Visiblity
|
||||
('visibility_public', 'dark gray', ''),
|
||||
('visibility_unlisted', 'white', ''),
|
||||
('visibility_private', 'dark cyan', ''),
|
||||
('visibility_direct', 'yellow', ''),
|
||||
|
||||
# Styles
|
||||
('bold', ',bold', ''),
|
||||
('blue', 'light blue', ''),
|
||||
('cyan', 'dark cyan', ''),
|
||||
('gray', 'dark gray', ''),
|
||||
('green', 'dark green', ''),
|
||||
('yellow', 'yellow', ''),
|
||||
('red', 'dark red', ''),
|
||||
('dim', 'dark gray', ''),
|
||||
('highlight', 'yellow', ''),
|
||||
('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'),
|
||||
@ -54,25 +66,34 @@ MONO_PALETTE = [
|
||||
('intro_bigtext', 'white', 'black'),
|
||||
('intro_smalltext', 'white', 'black'),
|
||||
('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
|
||||
('hashtag_followed', 'white,bold', 'black'),
|
||||
('hashtag', 'white,bold', 'black'),
|
||||
('link', ',italics', 'black'),
|
||||
('link_focused', ',bold,italics', 'black'),
|
||||
('account', 'dark green', ''),
|
||||
('hashtag_followed', 'white,bold', ''),
|
||||
('hashtag', 'white,bold', ''),
|
||||
('link', ',italics', ''),
|
||||
('link_focused', ',bold,italics', ''),
|
||||
('shortcut', 'white', ''),
|
||||
('shortcut_highlight', 'white,bold', ''),
|
||||
|
||||
# Colors
|
||||
('bold', ',bold', 'black'),
|
||||
('blue', 'white', 'black'),
|
||||
('cyan', 'white', 'black'),
|
||||
('gray', 'white', 'black'),
|
||||
('green', 'white', 'black'),
|
||||
('yellow', 'white', 'black'),
|
||||
('red', 'white', 'black'),
|
||||
('warning', 'white,bold', 'black'),
|
||||
# Visiblity
|
||||
('visibility_public', 'white', ''),
|
||||
('visibility_unlisted', 'white', ''),
|
||||
('visibility_private', 'white', ''),
|
||||
('visibility_direct', 'white', ''),
|
||||
|
||||
# Styles
|
||||
('bold', ',bold', ''),
|
||||
('dim', 'light gray', ''),
|
||||
('highlight', ',bold', ''),
|
||||
('success', '', ''),
|
||||
]
|
||||
|
||||
VISIBILITY_OPTIONS = [
|
||||
|
@ -196,7 +196,7 @@ class Help(urwid.Padding):
|
||||
|
||||
def generate_contents(self):
|
||||
def h(text):
|
||||
return highlight_keys(text, "cyan")
|
||||
return highlight_keys(text, "shortcut")
|
||||
|
||||
yield urwid.Text(("bold", "toot {}".format(__version__)))
|
||||
yield urwid.Divider()
|
||||
@ -260,10 +260,10 @@ class Account(urwid.ListBox):
|
||||
yield Button("Cancel", on_press=cancel_action, user_data=self)
|
||||
else:
|
||||
if self.user.username == account["acct"]:
|
||||
yield urwid.Text(("light gray", "This is your account"))
|
||||
yield urwid.Text(("dim", "This is your account"))
|
||||
else:
|
||||
if relationship['requested']:
|
||||
yield urwid.Text(("light gray", "< Follow request is pending >"))
|
||||
yield urwid.Text(("dim", "< Follow request is pending >"))
|
||||
else:
|
||||
yield Button("Unfollow" if relationship['following'] else "Follow",
|
||||
on_press=confirm_action, user_data=self)
|
||||
@ -275,7 +275,7 @@ class Account(urwid.ListBox):
|
||||
|
||||
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"]:
|
||||
yield urwid.Divider()
|
||||
@ -283,12 +283,12 @@ class Account(urwid.ListBox):
|
||||
yield urwid.Text(highlight_hashtags(line, followed_tags=set()))
|
||||
|
||||
yield urwid.Divider()
|
||||
yield urwid.Text(["ID: ", ("green", f"{account['id']}")])
|
||||
yield urwid.Text(["Since: ", ("green", f"{account['created_at'][:10]}")])
|
||||
yield urwid.Text(["ID: ", ("highlight", f"{account['id']}")])
|
||||
yield urwid.Text(["Since: ", ("highlight", f"{account['created_at'][:10]}")])
|
||||
yield urwid.Divider()
|
||||
|
||||
if account["bot"]:
|
||||
yield urwid.Text([("green", "Bot \N{robot face}")])
|
||||
yield urwid.Text([("highlight", "Bot \N{robot face}")])
|
||||
yield urwid.Divider()
|
||||
if account["locked"]:
|
||||
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.Divider()
|
||||
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()
|
||||
if relationship["blocked_by"]:
|
||||
yield urwid.Text(("warning", "Blocks you \N{no entry}"))
|
||||
yield urwid.Divider()
|
||||
|
||||
yield urwid.Text(["Followers: ", ("yellow", f"{account['followers_count']}")])
|
||||
yield urwid.Text(["Following: ", ("yellow", f"{account['following_count']}")])
|
||||
yield urwid.Text(["Statuses: ", ("yellow", f"{account['statuses_count']}")])
|
||||
yield urwid.Text(["Followers: ", ("highlight", f"{account['followers_count']}")])
|
||||
yield urwid.Text(["Following: ", ("highlight", f"{account['following_count']}")])
|
||||
yield urwid.Text(["Statuses: ", ("highlight", f"{account['statuses_count']}")])
|
||||
|
||||
if account["fields"]:
|
||||
for field in account["fields"]:
|
||||
name = field["name"].title()
|
||||
yield urwid.Divider()
|
||||
yield urwid.Text([("yellow", f"{name.rstrip(':')}"), ":"])
|
||||
yield urwid.Text([("bold", f"{name.rstrip(':')}"), ":"])
|
||||
for line in format_content(field["value"]):
|
||||
yield urwid.Text(highlight_hashtags(line, followed_tags=set()))
|
||||
if field["verified_at"]:
|
||||
yield urwid.Text(("green", "✓ Verified"))
|
||||
yield urwid.Text(("success", "✓ Verified"))
|
||||
|
||||
yield urwid.Divider()
|
||||
yield link("", account["url"])
|
||||
|
@ -61,7 +61,7 @@ class Poll(urwid.ListBox):
|
||||
|
||||
if poll["voted"] or poll["expired"]:
|
||||
prefix = " ✓ " if voted_for else " "
|
||||
yield urwid.Text(("gray", prefix + f'{option["title"]}'))
|
||||
yield urwid.Text(("dim", prefix + f'{option["title"]}'))
|
||||
else:
|
||||
if poll["multiple"]:
|
||||
checkbox = CheckBox(f'{option["title"]}')
|
||||
@ -83,7 +83,7 @@ class Poll(urwid.ListBox):
|
||||
)
|
||||
poll_detail += " · Closes on {}".format(expires_at)
|
||||
|
||||
yield urwid.Text(("gray", poll_detail))
|
||||
yield urwid.Text(("dim", poll_detail))
|
||||
|
||||
def generate_contents(self, status):
|
||||
yield urwid.Divider()
|
||||
|
@ -84,11 +84,10 @@ class Timeline(urwid.Columns):
|
||||
urwid.connect_signal(item, "click", lambda *args:
|
||||
self.tui.show_context_menu(status))
|
||||
return urwid.AttrMap(item, None, focus_map={
|
||||
"blue": "status_list_selected",
|
||||
"green": "status_list_selected",
|
||||
"yellow": "status_list_selected",
|
||||
"cyan": "status_list_selected",
|
||||
"red": "status_list_selected",
|
||||
"status_list_account": "status_list_selected",
|
||||
"status_list_timestamp": "status_list_selected",
|
||||
"highligh": "status_list_selected",
|
||||
"dim": "status_list_selected",
|
||||
None: "status_list_selected",
|
||||
})
|
||||
|
||||
@ -323,13 +322,13 @@ class StatusDetails(urwid.Pile):
|
||||
def content_generator(self, status, reblogged_by):
|
||||
if reblogged_by:
|
||||
text = "♺ {} boosted".format(reblogged_by.display_name or reblogged_by.username)
|
||||
yield ("pack", urwid.Text(("gray", text)))
|
||||
yield ("pack", urwid.AttrMap(urwid.Divider("-"), "gray"))
|
||||
yield ("pack", urwid.Text(("dim", text)))
|
||||
yield ("pack", urwid.AttrMap(urwid.Divider("-"), "dim"))
|
||||
|
||||
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.Divider())
|
||||
|
||||
@ -348,7 +347,7 @@ class StatusDetails(urwid.Pile):
|
||||
media = status.data["media_attachments"]
|
||||
if 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"], ")"]))
|
||||
if m["description"]:
|
||||
yield ("pack", urwid.Text(m["description"]))
|
||||
@ -367,7 +366,7 @@ class StatusDetails(urwid.Pile):
|
||||
application = status.data.get("application") or {}
|
||||
application = application.get("name")
|
||||
|
||||
yield ("pack", urwid.AttrWrap(urwid.Divider("-"), "gray"))
|
||||
yield ("pack", urwid.AttrWrap(urwid.Divider("-"), "dim"))
|
||||
|
||||
translated_from = (
|
||||
language_name(status.original.translated_from)
|
||||
@ -376,24 +375,24 @@ class StatusDetails(urwid.Pile):
|
||||
)
|
||||
|
||||
visibility_colors = {
|
||||
"public": "gray",
|
||||
"unlisted": "white",
|
||||
"private": "cyan",
|
||||
"direct": "yellow"
|
||||
"public": "visibility_public",
|
||||
"unlisted": "visibility_unlisted",
|
||||
"private": "visibility_private",
|
||||
"direct": "visibility_direct"
|
||||
}
|
||||
|
||||
visibility = status.visibility.title()
|
||||
visibility_color = visibility_colors.get(status.visibility, "gray")
|
||||
visibility_color = visibility_colors.get(status.visibility, "dim")
|
||||
|
||||
yield ("pack", urwid.Text([
|
||||
("blue", f"{status.created_at.strftime('%Y-%m-%d %H:%M')} "),
|
||||
("red" if status.bookmarked else "gray", "b "),
|
||||
("gray", f"⤶ {status.data['replies_count']} "),
|
||||
("yellow" if status.reblogged else "gray", f"♺ {status.data['reblogs_count']} "),
|
||||
("yellow" if status.favourited else "gray", f"★ {status.data['favourites_count']}"),
|
||||
("status_detail_timestamp", f"{status.created_at.strftime('%Y-%m-%d %H:%M')} "),
|
||||
("status_detail_bookmarked" if status.bookmarked else "dim", "b "),
|
||||
("dim", f"⤶ {status.data['replies_count']} "),
|
||||
("highlight" if status.reblogged else "dim", f"♺ {status.data['reblogs_count']} "),
|
||||
("highlight" if status.favourited else "dim", f"★ {status.data['favourites_count']}"),
|
||||
(visibility_color, f" · {visibility}"),
|
||||
("yellow", f" · Translated from {translated_from} " if translated_from else ""),
|
||||
("gray", f" · {application}" if application else ""),
|
||||
("highlight", f" · Translated from {translated_from} " if translated_from else ""),
|
||||
("dim", f" · {application}" if application else ""),
|
||||
]))
|
||||
|
||||
# Push things to bottom
|
||||
@ -405,9 +404,9 @@ class StatusDetails(urwid.Pile):
|
||||
return urwid.LineBox(contents)
|
||||
|
||||
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"):
|
||||
yield urwid.Text(["by ", ("yellow", card["author_name"].strip())])
|
||||
yield urwid.Text(["by ", ("card_author", card["author_name"].strip())])
|
||||
yield urwid.Text("")
|
||||
if card["description"]:
|
||||
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")
|
||||
status += " · Closes on {}".format(expires_at)
|
||||
|
||||
yield urwid.Text(("gray", status))
|
||||
yield urwid.Text(("dim", status))
|
||||
|
||||
|
||||
class StatusListItem(SelectableColumns):
|
||||
@ -452,20 +451,20 @@ class StatusListItem(SelectableColumns):
|
||||
)
|
||||
|
||||
edited_flag = "*" if edited_at else " "
|
||||
favourited = ("yellow", "★") if status.original.favourited else " "
|
||||
reblogged = ("yellow", "♺") if status.original.reblogged else " "
|
||||
is_reblog = ("cyan", "♺") if status.reblog else " "
|
||||
is_reply = ("cyan", "⤶") if status.original.in_reply_to else " "
|
||||
favourited = ("highlight", "★") if status.original.favourited else " "
|
||||
reblogged = ("highlight", "♺") if status.original.reblogged else " "
|
||||
is_reblog = ("dim", "♺") if status.reblog else " "
|
||||
is_reply = ("dim", "⤶") if status.original.in_reply_to else " "
|
||||
|
||||
return super().__init__([
|
||||
("pack", SelectableText(("blue", created_at), wrap="clip")),
|
||||
("pack", urwid.Text(("blue", edited_flag))),
|
||||
("pack", SelectableText(("status_list_timestamp", created_at), wrap="clip")),
|
||||
("pack", urwid.Text(("status_list_timestamp", edited_flag))),
|
||||
("pack", urwid.Text(" ")),
|
||||
("pack", urwid.Text(favourited)),
|
||||
("pack", urwid.Text(" ")),
|
||||
("pack", urwid.Text(reblogged)),
|
||||
("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_reblog)),
|
||||
("pack", urwid.Text(" ")),
|
||||
|
Loading…
Reference in New Issue
Block a user