Implement alternating full-width background for chat messages
This commit is contained in:
@@ -61,15 +61,23 @@ def main():
|
||||
# Apply emoji coloring using the new function
|
||||
message_text = colour_emoji(message_text)
|
||||
|
||||
# Alternate background styles
|
||||
background_style = Style(bgcolor="#2B2B2B") if message_count % 2 == 0 else Style(bgcolor="#3A3A3A")
|
||||
|
||||
# Simple color for username (can be expanded to unique colors per user)
|
||||
username_style = Style(color="#4CAF50", bold=True)
|
||||
|
||||
# Format message for terminal and log file
|
||||
# Format message for terminal
|
||||
formatted_message = f"[{username_style}]{author_display_name}[/]: {message_text}"
|
||||
console.print(formatted_message, style=background_style)
|
||||
|
||||
# Calculate padding to fill terminal width
|
||||
# rich handles rendering, so we need to calculate the visible width of the string
|
||||
# and pad it. This is a simplified approach, rich's Panel might be better for complex layouts.
|
||||
rendered_length = console.measure(formatted_message).cell_len
|
||||
padding = max(0, console.width - rendered_length)
|
||||
padded_message = f"{formatted_message}{' ' * padding}"
|
||||
|
||||
# Alternate background styles
|
||||
background_style = Style(bgcolor="#2B2B2B") if message_count % 2 == 0 else Style(bgcolor="#3A3A3A")
|
||||
|
||||
console.print(padded_message, style=background_style, overflow="crop")
|
||||
log_file.write(f"{datetime.now().strftime("%H:%M:%S")} {formatted_message}\n")
|
||||
message_count += 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user