On 10/17/20, Christopher Barker <python...@gmail.com> wrote:
>
> then how about os.clear_terminal() ?

IMO, an os level function such as os.clear_terminal(fd) should only
support terminal/console devices and would be implemented in
Modules/posixmodule.c. Higher-level behavior and support for IDEs
belongs in shutil.

> Sure, there's a manageable set of default terminals across the major OSs
> (and lInux Desktops), but there are a LOT of others as well, including
> IDEs, and even the new Terminal in Windows:

I would expect os.clear_terminal() to make exceptions only for popular
terminals/consoles, if they don't support the common ANSI sequence to
clear the screen.

In Windows 10, you can enable virtual terminal (VT) mode by default
for all non-legacy console sessions by setting "VirtualTerminalLevel"
to 1 in "HKCU\Console". VT mode supports the standard ANSI sequences
for clearing the terminal and/or scrollback. Regardless of the
VirtualTerminalLevel setting, each tab in Windows Terminal is a
headless pseudoconsole session (ConPTY) that has VT mode enabled by
default.

In all supported versions of Windows, if VT mode is disabled or not
supported, as determined by GetConsoleMode, then the console screen
buffer can be scrolled or cleared via GetConsoleScreenBufferInfo and
ScrollConsoleScreenBuffer, and the cursor can be reset to (0,0) via
SetConsoleCursorPosition.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/7TNXGFFPEUUGX7GTL4S4JRV4Q42EJTLL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to