edited and deleted markers in topics view

This commit is contained in:
chiptune 2023-11-19 06:56:12 -06:00
parent 6cdf315f07
commit e2e619a5d7
1 changed files with 16 additions and 3 deletions

19
iris.py
View File

@ -365,18 +365,31 @@ class Display:
print(f" {topic_no}{' '*(max_numlen-len(str(topic_no)))} \x1b[33m{author}{' '*(max_namelen-len(author))}\033[00m \033[96m{tstamp}\033[00m {content_part[:(COLS-max_namelen-tstamp_len-max_numlen-5)]}")
def print_message(msg, linecolor=False):
def print_message(msg, linecolor=False) -> None:
COLS = shutil.get_terminal_size((80, 20))[0]
text = msg["data"]["message"]
tstamp = msg["data"]["timestamp"].split('T')[0]
author = msg["data"]["author"].split('@')[0]
edited = "edited" if msg["edit_hash"] else ""
space = COLS - (len(author) + len(tstamp) + 1) - 3
if msg["is_deleted"]:
space = COLS - (len(author) + len(tstamp) + 1) - 3 - 7
print(f" \x1b[33m{author}\033[00m \x1b[37m{tstamp}\033[00m {'-'*space} \x1b[33mDELETED\033[00m")
if linecolor:
print(f" \x1b[33m{author}\033[00m \x1b[37m{tstamp}\033[00m \033[96m{'-'*space}\033[00m")
if edited:
space = COLS - (len(author) + len(tstamp) + 1) - 3 - 7
print(f" \x1b[33m{author}\033[00m \x1b[37m{tstamp}\033[00m \033[96m{'-'*space}\033[00m \033[96m{edited}\033[00m")
else:
print(f" \x1b[33m{author}\033[00m \x1b[37m{tstamp}\033[00m \033[96m{'-'*space}\033[00m")
else:
print(f" \x1b[33m{author}\033[00m \x1b[37m{tstamp}\033[00m {'-'*space}")
if edited:
space = COLS - (len(author) + len(tstamp) + 1) - 3 - 7
print(f" \x1b[33m{author}\033[00m \x1b[37m{tstamp}\033[00m {'-'*space} \033[96m{edited}\033[00m")
else:
print(f" \x1b[33m{author}\033[00m \x1b[37m{tstamp}\033[00m {'-'*space}")
print(text)
if text[-1] != '\n':