[Python-ideas] Suggestion: Clear screen command for the REPL

eryk sun eryksun at gmail.com
Mon Sep 19 10:45:53 EDT 2016


On Mon, Sep 19, 2016 at 1:12 PM, Paul Moore <p.f.moore at gmail.com> wrote:
> By the way - if you're on a system with readline support included with
> Python, GNU readline apparently has a binding for clear-screen
> (CTRL-L) so you may well have this functionality already (I don;'t use
> Unix or readline, so I can't comment for sure).

Hooking Ctrl+L to clear the screen can be implemented for Windows
Vista and later via the ReadConsole pInputControl parameter, as called
by PyOS_StdioReadline. It should be possible to match how GNU readline
works -- i.e. clear the screen, reprint the prompt, flush the input
buffer, and write the current line's input back to the input buffer.

The pInputControl parameter can also be used to implement Unix-style
Ctrl+D to end a read anywhere on a line, whereas the classic
[Ctrl+Z][Enter] has to be entered at the start of a line.


More information about the Python-ideas mailing list