Fix padding

This commit is contained in:
Huy Ngo 2024-08-05 09:22:10 +07:00
parent 2989101e67
commit 3ce4a7148a

View file

@ -292,9 +292,10 @@ def print_status(status: Status, width: int = 80, padding: int = 0):
if display_name:
spacing -= wcswidth(display_name) + 1
paddings = "" * padding
print_out(
"" * padding,
f"<green>{display_name}</green>" if display_name else "",
paddings + (f"<green>{display_name}</green>" if display_name else ""),
f"<blue>{username}</blue>",
" " * spacing,
f"<yellow>{time}</yellow>",
@ -302,35 +303,34 @@ def print_status(status: Status, width: int = 80, padding: int = 0):
print_out("" * padding)
if status.spoiler_text:
print_out("" * padding, "<yellow>Subject</yellow>: ", end="")
print_out(paddings + "<yellow>Subject</yellow>: ", end="")
print_html(status.spoiler_text)
print_out("" * padding)
print_out(paddings)
print_html(status.content, width, padding)
if status.media_attachments:
print_out(f"{'' * padding}\n{'' * padding}Media:")
print_out(f"{paddings}\n{paddings}Media:")
for count, attachment in enumerate(status.media_attachments):
url = attachment.url
description = f'Description: {attachment.description}'
print_out(f'{"" * padding}{count+1}. <yellow>URL</yellow>: {url}')
print_out(f'{paddings}{count+1}. <yellow>URL</yellow>: {url}')
for i, line in enumerate(wc_wrap(description, width - padding)):
if i == 0:
line = line.replace('Description', '<yellow>Description</yellow>')
print_out('' * padding + line)
print_out(paddings + line)
if status.poll:
print_poll(status.poll)
print_out("" * padding)
print_out(paddings)
reacts = ("\n" * padding + " ").join([f'{react.count} × {react.name}'
reacts = ('\n' + paddings).join([f'{react.count} × {react.name}'
for react in status.emoji_reactions])
if reacts:
reacts = "" * padding + " " + reacts
reacts = paddings + reacts
print_out(
"" * padding,
f"<yellow>Reacts:</yellow>\n{reacts}\n{'' * padding}" if reacts else "",
paddings + (f"<yellow>Reacts:</yellow>\n{reacts}\n{paddings}" if reacts else ""),
f"ID <yellow>{status_id}</yellow> ",
f"↲ In reply to <yellow>{in_reply_to_id}</yellow> " if in_reply_to_id else "",
f"↻ <blue>@{reblogged_by.acct}</blue> boosted " if reblogged_by else "",
@ -344,7 +344,7 @@ def print_html(text, width=80, padding=0):
print_out("" * padding)
for line in paragraph:
for subline in wc_wrap(line, width):
print_out("" * padding, highlight_hashtags(subline))
print_out("" * padding + highlight_hashtags(subline))
first = False