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
Offer option to clear screen after earch rerun #4
Comments
Hey @estevaoem, I agree that clearing the screen can be really useful, but I am not sure if this can be achieved that easily and will work on all systems. I will take a time to evaluate possible ways to implement this. Appreciate your idea! |
Yeah, true. I was doing some tests with |
Use ipython (license BSD-3) has across-platform clear screen, ipython.utils.terminal::_term_clear(): if os.name == 'posix':
def _term_clear():
os.system('clear')
elif sys.platform == 'win32':
def _term_clear():
os.system('cls')
else:
def _term_clear():
pass Used in its demo. @estevaoem Interested in making a PR so we can demo it? Edit (2022-10-30): Updated ipython links 8.2.0 -> 8.6.0 |
@tony Thanks for providing this snippet. |
I have no opinion on it, only since it was ipython's approach and they're widely used: so I expect it's robust. |
@tony, currently I'm using the following solution:
|
any updates? |
May i propose a tricky solution, Ansi escape sequence:
this can be summurized with |
I suspect the reason this issue is (and might stay) off the radar despite being marked as |
I currently do not have much time to implement this. Will hopefully be able to work on that next month. @bard The tricky part for me is testing on Windows machines, cause I personally don't use one. |
@Pixailz looks quite hacky, will probably be hard to maintain that in future. |
@olzhasar not that much, it's a specification to manipulate the terminal, this link easily show what's possible with ANSI Escaped Sequence. In fact that's just a sequence of character printed out to the terminal, and the terminal interpret those as "command", and it's pretty universal to be honest i don't how to put this little a little script to see if it work on OS's is available here |
The OG |
@aaaaahaaaaa Good idea. Just to save people some hunting: is_windows = sys.platform == 'win32'
# ...
def clear():
"""
Clears the terminal.
"""
subprocess.call('cls' if is_windows else 'clear', shell=True) |
ANSI escape codes were specified in 1976 in the ECMA-48 standard, that's nearly 48 years ago, it's a pretty safe bet that it will be easy to support them for that many more years to come. Sending those escape codes is exactly what The ones used in the snippet are called Erase Display and CUrsor Position, see wikipedia. |
A new version with clear screen support has just been released. Thank you everyone for your suggestions! |
Hello @olzhasar. First of all, thanks for your contribution, its really handy.
I'd suggest a little modification at the function
To something like
To clear the results before each test.
Thanks!!
The text was updated successfully, but these errors were encountered: