[PATCH] Strange behavior of cmd.exe when hammered with clear screen operations from Cygwin program.

Kaz Kylheku kaz@kylheku.com
Wed Jul 27 21:30:00 GMT 2016

On 27.07.2016 11:45, Corinna Vinschen wrote:
> Btw, since you're apparently building your own Cygwin DLL I thought 
> just
> sending the patch for testing is sufficient.  If you prefer to get a
> developer snapshot with this patch, I can do that, too.  Just say the 
> word.

The patch looks good and in many cases avoids padding the history with
blank lines, compared to the naive newline emission approach.

Usually, the clear screen operation is preceded by a homing of the 
I.e., in VT100 language:  ESC [ H, ESC [ 2 J.  In this case, your 
seems to nicely trim the console data at that line. Rather, that is to
say, when we scroll back, there aren't any blank lines, since none were
added; the clear was done as a pure scrolling operation without any
padding data.

Blank lines are only generated if the cursor is in the middle of the
buffer. Since the cursor position is restored after the scrolling,
that then adds blank lines between the scrolled-away material and the
cursor position. And if the clear is repeated at that position,
more blank lines are added for each repetition. Who cares about that 

Other implementations behave the same way, if not worse.

Case in point: Gnome Terminal ( behaves like my naive \n
repetition patch! Every issue of ESC [ 2 J adds a window height's
worth of blank lines to the history,  regardless of the position
of the cursor!  That is what I compared to as a "gold standard",
so I was okay with it.

Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

More information about the Cygwin mailing list