-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Styled text wraps incorrectly after capture #2907
Comments
The escape sequences in the captured text break wrapping / formatting. They may also interfere with any additional styles you apply. You should find that if you use a plain old print or write to stdout you will get the results you expect. You could also use console.print(Text.from_ansi(captured)) This isn't done by default, because it costs a little cpu and there are some situations where you really want those escape sequences to be written out unmodified. |
Thanks. I my project (https://github.com/nedbat/watchgha) I'm using console.screen: with console.screen() as screen:
while not done:
screen.update(output)
time.sleep(1) which wraps |
What was the reasoning behind capturing the output? You can pass any renderable to |
I wanted to get the latest output and then either display it on the alternate screen, or straight to the console, depending on if it was the last update (done == True). |
I hope we solved your problem. If you like using Rich, you might also enjoy Textual |
Describe the bug
I have text with styling that can get long. When I use console.capture() and then later print it with console.print(), it's wrapped incorrectly. Using console.print() directly wraps it correctly.
Code:
Platform
Click to expand
This is Mac using iTerm2. The result is the same using Terminal.
I may ask you to copy and paste the output of the following commands. It may save some time if you do it now.
If you're using Rich in a terminal:
The text was updated successfully, but these errors were encountered: