Replies: 1 comment
-
|
Please write this in your own words. Otherwise I'll assume it's not important to you. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Allow Live to stop without emitting a final newline
Summary
Live.stop()currently emits a final newline after the last refresh when the live render has a height:That default is useful for most CLIs because subsequent output starts below the live display. Some CLIs, however, intentionally reserve and manage their own trailing line so the shell prompt can land there without causing the table/display to scroll at program exit.
Proposal
Add a
final_newline: bool = Trueoption toLive.Truekeeps the current behavior.Falsesuppresses the finalconsole.line()inLive.stop().Use case
A live table can reserve a prompt landing line below itself, backfill/update in place, and then leave the cursor on that existing line. Without an opt-out, Rich’s final newline can create an extra line at stop time and scroll the table even though the application has already reserved space.
Demo
The following short demo script can be run with or without the proposed implementation. By default, it displays a small live table, simulates the table updating for a moment, and then closes. With current Rich behavior, the final newline can make the table scroll by one line as the program exits.
On the prepared branch linked below, run the same script with
--final-newline falseto see the display stop without Rich adding that final newline.This is not a big deal for interactive programs where the user explicitly quits the live display. It is more noticeable for slow-updating output that automatically closes, because the display can move while someone is still reading it.
live_final_newline_demo.py
Compatibility
This would be backward compatible because the default remains
True.Prepared branch
I have a small implementation ready on my fork:
https://github.com/darlingm/rich/tree/feature/live/optional-final-newline
If this approach is approved, I am ready to open an issue and a pull request that addresses it.
AI disclosure
This discussion text was drafted with OpenAI Codex.
Beta Was this translation helpful? Give feedback.
All reactions