mirror of
https://github.com/ihabunek/toot.git
synced 2025-06-30 22:18:36 -04:00
parent
45e78fa286
commit
65f426fbcb
@ -45,6 +45,12 @@ COLOR_OPTIONS = ", ".join(TUI_COLORS.keys())
|
|||||||
type=click.Choice(IMAGE_FORMAT_CHOICES),
|
type=click.Choice(IMAGE_FORMAT_CHOICES),
|
||||||
help="Image output format; support varies across terminals. Default: block"
|
help="Image output format; support varies across terminals. Default: block"
|
||||||
)
|
)
|
||||||
|
@click.option(
|
||||||
|
"--show-display-names",
|
||||||
|
is_flag=True,
|
||||||
|
default=False,
|
||||||
|
help="Show display names instead of account names in the list view."
|
||||||
|
)
|
||||||
@pass_context
|
@pass_context
|
||||||
def tui(
|
def tui(
|
||||||
ctx: Context,
|
ctx: Context,
|
||||||
@ -54,7 +60,8 @@ def tui(
|
|||||||
relative_datetimes: bool,
|
relative_datetimes: bool,
|
||||||
cache_size: Optional[int],
|
cache_size: Optional[int],
|
||||||
default_visibility: Optional[str],
|
default_visibility: Optional[str],
|
||||||
image_format: Optional[str]
|
image_format: Optional[str],
|
||||||
|
show_display_names: bool,
|
||||||
):
|
):
|
||||||
"""Launches the toot terminal user interface"""
|
"""Launches the toot terminal user interface"""
|
||||||
if colors is None:
|
if colors is None:
|
||||||
@ -68,6 +75,7 @@ def tui(
|
|||||||
default_visibility=default_visibility,
|
default_visibility=default_visibility,
|
||||||
always_show_sensitive=always_show_sensitive,
|
always_show_sensitive=always_show_sensitive,
|
||||||
image_format=image_format,
|
image_format=image_format,
|
||||||
|
show_display_names=show_display_names,
|
||||||
)
|
)
|
||||||
tui = TUI.create(ctx.app, ctx.user, options)
|
tui = TUI.create(ctx.app, ctx.user, options)
|
||||||
tui.run()
|
tui.run()
|
||||||
|
@ -40,6 +40,7 @@ class TuiOptions(NamedTuple):
|
|||||||
cache_size: int
|
cache_size: int
|
||||||
default_visibility: Optional[str]
|
default_visibility: Optional[str]
|
||||||
image_format: Optional[str]
|
image_format: Optional[str]
|
||||||
|
show_display_names: bool
|
||||||
|
|
||||||
|
|
||||||
class Header(urwid.WidgetWrap):
|
class Header(urwid.WidgetWrap):
|
||||||
@ -97,12 +98,12 @@ class TUI(urwid.Frame):
|
|||||||
screen: urwid.BaseScreen
|
screen: urwid.BaseScreen
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create(app: App, user: User, args: TuiOptions):
|
def create(app: App, user: User, options: TuiOptions):
|
||||||
"""Factory method, sets up TUI and an event loop."""
|
"""Factory method, sets up TUI and an event loop."""
|
||||||
screen = TuiScreen()
|
screen = TuiScreen()
|
||||||
screen.set_terminal_properties(args.colors)
|
screen.set_terminal_properties(options.colors)
|
||||||
|
|
||||||
tui = TUI(app, user, screen, args)
|
tui = TUI(app, user, screen, options)
|
||||||
|
|
||||||
palette = PALETTE.copy()
|
palette = PALETTE.copy()
|
||||||
overrides = settings.get_setting("tui.palette", dict, {})
|
overrides = settings.get_setting("tui.palette", dict, {})
|
||||||
|
@ -87,7 +87,7 @@ class Timeline(urwid.Columns):
|
|||||||
return urwid.ListBox(walker)
|
return urwid.ListBox(walker)
|
||||||
|
|
||||||
def build_list_item(self, status):
|
def build_list_item(self, status):
|
||||||
item = StatusListItem(status, self.tui.options.relative_datetimes)
|
item = StatusListItem(status, self.tui.options)
|
||||||
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={
|
||||||
@ -593,14 +593,14 @@ class StatusDetails(urwid.Pile):
|
|||||||
|
|
||||||
|
|
||||||
class StatusListItem(SelectableColumns):
|
class StatusListItem(SelectableColumns):
|
||||||
def __init__(self, status, relative_datetimes):
|
def __init__(self, status, options):
|
||||||
edited_at = status.original.edited_at
|
edited_at = status.original.edited_at
|
||||||
|
|
||||||
# TODO: hacky implementation to avoid creating conflicts for existing
|
# TODO: hacky implementation to avoid creating conflicts for existing
|
||||||
# pull requests, refactor when merged.
|
# pull requests, refactor when merged.
|
||||||
created_at = (
|
created_at = (
|
||||||
time_ago(status.created_at).ljust(3, " ")
|
time_ago(status.created_at).ljust(3, " ")
|
||||||
if relative_datetimes
|
if options.relative_datetimes
|
||||||
else status.created_at.strftime("%Y-%m-%d %H:%M")
|
else status.created_at.strftime("%Y-%m-%d %H:%M")
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -610,6 +610,10 @@ class StatusListItem(SelectableColumns):
|
|||||||
is_reblog = ("dim", "♺") if status.reblog else " "
|
is_reblog = ("dim", "♺") if status.reblog else " "
|
||||||
is_reply = ("dim", "⤶ ") if status.original.in_reply_to else " "
|
is_reply = ("dim", "⤶ ") if status.original.in_reply_to else " "
|
||||||
|
|
||||||
|
display_name = status.original.author.display_name
|
||||||
|
account_name = status.original.account
|
||||||
|
name = display_name if display_name and options.show_display_names else account_name
|
||||||
|
|
||||||
return super().__init__([
|
return super().__init__([
|
||||||
("pack", SelectableText(("status_list_timestamp", created_at), wrap="clip")),
|
("pack", SelectableText(("status_list_timestamp", created_at), wrap="clip")),
|
||||||
("pack", urwid.Text(("status_list_timestamp", edited_flag))),
|
("pack", urwid.Text(("status_list_timestamp", edited_flag))),
|
||||||
@ -618,7 +622,7 @@ class StatusListItem(SelectableColumns):
|
|||||||
("pack", urwid.Text(" ")),
|
("pack", urwid.Text(" ")),
|
||||||
("pack", urwid.Text(reblogged)),
|
("pack", urwid.Text(reblogged)),
|
||||||
("pack", urwid.Text(" ")),
|
("pack", urwid.Text(" ")),
|
||||||
urwid.Text(("status_list_account", status.original.account), wrap="clip"),
|
urwid.Text(("status_list_account", name), 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…
x
Reference in New Issue
Block a user