diff --git a/toot/tui/constants.py b/toot/tui/constants.py index e2aec90..29b2997 100644 --- a/toot/tui/constants.py +++ b/toot/tui/constants.py @@ -4,7 +4,7 @@ PALETTE = [ ('button', 'white', 'black'), ('button_focused', 'light gray', 'dark magenta'), ('editbox', 'white', 'black'), - ('editbox_focused', '', 'dark magenta'), + ('editbox_focused', 'white', 'dark magenta'), ('footer_message', 'dark green', ''), ('footer_message_error', 'light red', ''), ('footer_status', 'white', 'dark blue'), @@ -13,6 +13,7 @@ PALETTE = [ ('header_bold', 'white,bold', 'dark blue'), ('intro_bigtext', 'yellow', ''), ('intro_smalltext', 'light blue', ''), + ('content_warning', 'white', 'dark magenta'), # Functional ('hashtag', 'light cyan,bold', ''), diff --git a/toot/tui/entities.py b/toot/tui/entities.py index da2d84f..a0cadc6 100644 --- a/toot/tui/entities.py +++ b/toot/tui/entities.py @@ -24,6 +24,9 @@ class Status: self.data = data self.instance = instance + # This can be toggled by the user + self.show_sensitive = False + # TODO: make Status immutable? self.id = self.data["id"] diff --git a/toot/tui/timeline.py b/toot/tui/timeline.py index 9240675..a368f96 100644 --- a/toot/tui/timeline.py +++ b/toot/tui/timeline.py @@ -122,6 +122,11 @@ class Timeline(urwid.Columns): self._emit("reply", status) return + if key in ("s", "S"): + status.show_sensitive = True + self.refresh_status_details() + return + if key in ("t", "T"): self._emit("thread", status) return @@ -194,8 +199,16 @@ class StatusDetails(urwid.Pile): yield ("pack", urwid.Text(("yellow", status.author.account))) yield ("pack", urwid.Divider()) - for line in format_content(status.data["content"]): - yield ("pack", urwid.Text(highlight_hashtags(line))) + if status.data["spoiler_text"]: + yield ("pack", urwid.Text(status.data["spoiler_text"])) + yield ("pack", urwid.Divider()) + + # Show content warning + if status.data["spoiler_text"] and not status.show_sensitive: + yield ("pack", urwid.Text(("content_warning", "Marked as sensitive. Press S to view."))) + else: + for line in format_content(status.data["content"]): + yield ("pack", urwid.Text(highlight_hashtags(line))) media = status.data["media_attachments"] if media: