-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
clear
doesn't take effect immediately on Linux
#2284
Comments
Using Also, there's no need for the |
Yes I was thinking it had to do something with the flushing of the buffer. The last snippet of code I pasted was modified from
What do you think? |
Yes, I tried that earlier on Linux and Windows and it worked. You're welcome to make a PR, or I will later. |
If it's not urgent I'll do it in a few hours (tomorrow) |
See pallets#2284 for details
PR #2286 should be good to go! Sorry I made another one and then closed it, it's my first PR to a public repo, I wanted to update it again to let it pass all the checks. |
clear
doesn't take effect immediately on Linux
Hi! I'm writing a small script and I'm using
click
for user input and console text formatting. In practice, I use theclick.getchar()
function to read a single char from stdin, and do some processing from there; I construct a string representing a visual representation of the output and I print it. But! Whenever I useclick.clear()
instead ofos.system('clear')
, I get an inconsistent behavior: the terminal doesn't get cleared at the beginning of the script,Here is a minimal reproducible example (imports omitted for brevity):
script1.py
python3 script1.py
-> the terminal gets cleared and there's only the blinking cursor; this is the expected behavior. Instead, here'sscript2.py
:python3 script2.py
-> see:The terminal doesn't get cleared, I can still see my username, the command, etc. Obviously this is trivial to circumvent; my implementation is:
Something like this could be mainlined in
click.clear()
, for example something like (taking from the current implementation):Obviously the default value would follow the current behavior for consistency. I hope I've been thorough enough. Thanks!
The text was updated successfully, but these errors were encountered: