Replies: 1 comment
|
The behavior comes from a very specific line in So reserving a blank row inside the renderable cannot currently prevent the extra line: that row is part of the final Live frame, and Between the two API shapes, an explicit If this is accepted as a feature, I would keep the default One caveat before opening the PR: Rich's current AI policy says an AI-generated PR must link to an issue or discussion where the solution has been approved by @willmcgugan. So if AI is involved in the implementation, this discussion should get that maintainer approval first rather than treating the absence of objections as approval. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I have a table that can be displayed instantly, except for one column which takes a while to determine. I used
Liveto instantly print the table with the slow column blank, and backfill the empty cells as they're determined. This allows not waiting for the slow data before being able to see the rest of it. This worked great, except when it finishes and exits, the screen scrolls a line for the bash prompt to display. It's a bit jarring when I'm reading for it to scroll a line.So, I tried:
Group(table, Text("")).Live.stop()executed, manually moving the cursor up a line, moving to column 0, and clearing the line withconsole.file.write("\x1b[1A\r\x1b[2K").This didn't quite work. During the slow Live updating, there was the trailing blank line (intended for the shell prompt.) But, afterward, Rich emitted another newline which caused the table to scroll again even though the shell prompt wound up on the line after the table, with a blank line after it.
I'd like to submit an issue and a PR to give
Livean optional argument to skip printing the final newline when it's done. It would default to the current behavior of printing it so there's no change in behavior unless someone uses the new argument.live_final_newline_demo.py, included below, can run without any changes to Rich and demonstrate what I'm talking about. It immediately prints the table, sleeps a second to simulate the slowness, and updates the last column. It shows the scrolling that seems jarring to me. With the proposed implementation on my feature/live/optional-final-newline branch, you can run this with--final-newline falseto make the prompt land on the already reserved line.An alternative implementation would be to give Live an option like
reserve_final_line=Falseas a default, but when set to true it would automatically display a final blank line and leave the cursor on it when it's done. Then, the caller wouldn't have to emit an emptyTextline and wouldn't have to manually move the cursor. That would be a larger set of changes. I'd be happy to do it and submit it that way, but my first instinct was to keep the change smaller.live_final_newline_demo.py
EDIT: Follow-up to #4185 (fair enough!)
All reactions