Closed nineteendo closed 4 weeks ago
For reference, here's how I handled this in my own library: https://github.com/nineteendo/ansio/blob/125577e28362ed5395c3dafed38df763fa88b8c2/ansio/__init__.py
is there any updates to this?
Nope, this is one of the reasons why I don't use rich.
The cursor state is something managed by the terminal. It can be modified outside of a Console object, which makes knowing how to "reset" it next to impossible. Additionally, to detect the cursor state, you would need to capture stdin, which Rich doesn't do as it would break the many project that do capture stdin.
If you want control over the cursor state, put it in a try / finally, or a context manager.
I hope we solved your problem.
If you like using Rich, you might also enjoy Textual
to detect the cursor state, you would need to capture stdin
Can I detect that without using ansi escape codes? My library will always show the cursor on exit if you chose to hide it.
It can be modified outside of a Console object, which makes knowing how to "reset" it next to impossible.
In my project I'm not modifying the cursor at all. I've only used status
, Live
tables, and progress bars. I'd expect for using things the correct way it surely can manage its cursor itself.
Don't call input when any of these objects are running. Input will block and write to the terminal at the same time as Rich, and there is no way for Rich to detect this.
If you want a UI where you can get user input and update the screen, look in to a TUI framework like Textual.
When status
, Live
tables, or progress bars are shown there is no input being captured. In the case of status
and the progress bars its being used for long waiting tasks to show that something is happening than just a blank terminal
Describe the bug
On exit
Rich doesn't restore the terminal back to its original settings when the program terminates:
On suspend
Rich doesn't restore the terminal back to its original settings when the program is suspended:
Platform
Click to expand
```none ╭───────────────────────