Skip to content
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

Does clearing screen reset background also #366

Closed
sophiajt opened this issue Apr 18, 2020 · 6 comments
Closed

Does clearing screen reset background also #366

sophiajt opened this issue Apr 18, 2020 · 6 comments
Labels

Comments

@sophiajt
Copy link

Recently, we had someone file this issue for nushell: nushell/nushell#1599

It seems as though when they use the clear screen shortcut, rustyline is able to clear the screen. But, when there's a background color (like the red we use for errors), that doesn't get cleared.

Is there a way to enable clearing the background also?

@bjorn3
Copy link
Contributor

bjorn3 commented Apr 18, 2020

Unix uses \x1b[H\x1b[2J which clears the background:

self.write_and_flush(b"\x1b[H\x1b[2J")

Windows uses FillConsoleOutputCharacterA to fill the screen with spaces. It seems that this doesn't affect colors. According to https://docs.microsoft.com/en-us/windows/console/clearing-the-screen you need to call FillConsoleOutputAttribute as well.

check!(wincon::FillConsoleOutputCharacterA(
self.handle,
' ' as CHAR,
length,
pos,
&mut _count,
));

@gwenn
Copy link
Collaborator

gwenn commented Apr 19, 2020

Indeed, we should do both like

@gwenn
Copy link
Collaborator

gwenn commented Apr 19, 2020

Could you please give a try to PR #367 ?
Thanks.

@sophiajt
Copy link
Author

sophiajt commented Apr 19, 2020

Yes, this looks better. I couldn't get it to repro with this PR.

@sophiajt
Copy link
Author

@gwenn - can we merge this fix for the next release, too?

@gwenn
Copy link
Collaborator

gwenn commented Apr 23, 2020

@jonathandturner 6.1.2 has been published.

@gwenn gwenn closed this as completed Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants