On 22 Dec 2020, at 09:49, Barry Scott firstname.lastname@example.org wrote:
The simplest answer is
Are there any terminals that this does not work on that are in active use?
Is using curses that uses termcap needed these days?
Of course Windows is the outlier, but the new Windows Terminal supports ANSI escapes sequences and utf-8.
I tested the above with Windows Terminal 1.4 on Windows 10 and it just works.
Otherwise os.system('cls') works for windows terminal and the old windows console stuff.
It turns out that on Windows 10 it works for old console API if you do this:
----- import sys
def clear_terminal(): if sys.platform == 'win32': import ctypes kernel32 = ctypes.windll.kernel32 # turn on the console ANSI colour handling kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
sys.stdout.write('\x1b[2J' '\x1b[H') -----
The above should work in all but the old none ANSI terminals.