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

Corinna Vinschen corinna-cygwin@cygwin.com
Thu Jul 28 08:00:00 GMT 2016

On Jul 27 13:36, Kaz Kylheku wrote:
> 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 cursor.
> I.e., in VT100 language:  ESC [ H, ESC [ 2 J.  In this case, your approach
> 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 case,
> though.

I saw that and disregarded it as not overly important.  On second
thought there should be a matching scrolling operation for this case,
too, which does not waste buffer with empty lines.

> 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.

I checked against xfce4-terminal and konsole and both are rather

Thanks for testing.  I'll check in the patch as is for now, but I'd
still be interested to fix the aforementioned empty lines problem,
even if just for completeness.  If you have an idea, feel free to


Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20160728/3e39ece2/attachment.sig>

More information about the Cygwin mailing list