Fix multi-line background fill using Text.assemble and Text.pad_to_width
This commit is contained in:
@@ -118,10 +118,12 @@ def main():
|
||||
# Alternate background styles
|
||||
background_style = Style(bgcolor="#2B2B2B") if message_count % 2 == 0 else Style(bgcolor="#3A3A3A")
|
||||
|
||||
# Print the message, letting rich handle wrapping and filling the width
|
||||
# The 'width' parameter ensures the background fills the terminal width
|
||||
# We remove the manual padding and rely on rich's internal handling.
|
||||
console.print(full_message_text, style=background_style, width=console.width)
|
||||
# Create a Text object for the entire line with the background style
|
||||
# Then pad it to the full console width
|
||||
line_to_print = Text.assemble(full_message_text, style=background_style)
|
||||
line_to_print.pad_to_width(console.width, style=background_style)
|
||||
|
||||
console.print(line_to_print, overflow="crop")
|
||||
log_file.write(f"{datetime.now().strftime("%H:%M:%S")} {full_message_text.plain}\n")
|
||||
message_count += 1
|
||||
|
||||
@@ -137,4 +139,4 @@ def main():
|
||||
console.print(f"[green]Chat log saved to {log_filename}[/green]")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
Reference in New Issue
Block a user