[PATCH] Cygwin: pty: Disable clear screen for ssh sessions with -t option.
Tue Oct 22 00:10:00 GMT 2019
On Mon, 21 Oct 2019 11:43:56 +0200
Corinna Vinschen wrote:
> So it seems cmd.exe is the only (or one of few) native CLI tools
> actually trying to manipulate the screen buffer. And what it does is
> not so much clearing the screen, but to align buffer line 1 with the top
> of the screen, even if line 1 has been produced before cmd.exe started.
What is done is not clearing the screen, but redrawing the screen
based on the screen buffer. This is done not by cmd.exe but by pseudo
console, I believe. The trigger for redrawing is not clear to me.
You can see what is done by pseudo console by checking "typescript"
generated by script.
> I didn't look deeper into this yet, but the question coming to mind is,
> what does GetConsoleScreenBufferInfo return right after starting
> `env TERM=dumb script`, how does it look like right after running
> `reg.exe' and before `cmd.exe', and how does it look after cmd.exe
> changed it?
I confirmed the dwSize has right screen size and dwCursorPosition
is (0,0) just after creating pty even though the cursor position
in real screen is not at top left.
Clearing screen fixes this mismatch.
> The (admittedly vague) idea is, maybe cmd.exe can be cheated into
> not changing the console buffer by changing it to what it expects
> right after creating the pseudo console...
To do this, it is necessary to log past data written to pty and
push them into console screen buffer when pseudo console is started.
The console screen buffer is empty just after creating pseudo console,
therefore, clearing screen is the simplest way to match the real screen
with the console screen buffer.
Takashi Yano <email@example.com>
More information about the Cygwin-patches