-
Notifications
You must be signed in to change notification settings - Fork 2
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
Printing continues at wrong position when the terminal instance gets out of scope #11
Comments
That is weird, I have no clue why that happens. Over here https://github.com/crossterm-rs/terminal/blob/master/src/backend/crossterm/implementation.rs#L121 I have the drop function. Here it disables raw modes and goes back to the default screen. Since you haven't enabled raw modes and switched to alternate screen this 'shouldn't' do anything. However, maybe it triggers some terminal behavior. This can be tested by simply debugging and commenting on the functions in the drop method. |
The issue seems to be the
|
Are you able to reproduce the wrong behaviour? |
I can give it a shot in some hours |
@TimonPost Is there an update on this? I want to be able to write to stdout without the screen clearing whenever the terminal instance goes out of scope. For example, when the program ends I want to be able to see the command history. |
@phil0x2e @TimonPost I found that if one runs |
Hi there, correct, sorry I totally mist this issue. It's correct that raw modes, alternate screen, and mouse capture is disabled at the drop https://github.com/crossterm-rs/terminal/blob/master/src/backend/crossterm/implementation.rs#L122 I chose this behavior because when a program stops we need to disable those things such that the terminal is back into its original modes. A solution could be, is by storing the terminal instance in an Box or something like that. |
@TimonPost Like @bhgomes mentioned it also happens after the program terminates, so you'll never be able to print something, that still needs to be read after your program ended. That really limits the use of this library to very interactive applications. |
Take this Code (I'm using crossterm-backend):
The output for me looks something like this:
Is there a way to prevent this behaviour?
If not terminal seems to be not suited for use in a library, because anyone that's using the library would always need to keep an instance of the Terminal struct alive (Or at least a struct from the library using it, that itself keeps an instance of Terminal) to be able to properly print something afterwards.
EDIT:
Even when you just create an instance of Terminal and do nothing with it and end its scope, this problem occurs.
The text was updated successfully, but these errors were encountered: