public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* In Cygwin console (not Mintty), escape sequences DL/IL at the last line misbehave
@ 2022-02-03 10:02 Koichi Murase
  2022-02-03 12:09 ` Takashi Yano
  0 siblings, 1 reply; 4+ messages in thread
From: Koichi Murase @ 2022-02-03 10:02 UTC (permalink / raw)
  To: cygwin

I'm not sure what this exactly is related to, but I guess pcon is
closely related.

Cygwin version:

I can reproduce it in Cygwin 3.2.0 and the latest 3.3.4 for both
64-bit and 32-bit versions. I usually set CYGWIN=disable_pcon, but
this reproduces for both cases with and without disable_pcon.

I think I observed this behavior even earlier but don't exactly
remember in which Cygwin version I first noticed this broken behavior.
At least, this behavior has existed for a very long time. I have been
thinking that there are a few people using the Cygwin console
directly, but I recently noticed that it matters when I connect to
Cygwin from Windows Terminal. This puts very hard limitations on
implementing a line editor where the line editor does not know the
absolute vertical position in the terminal screen so cannot predict
the consequences of using DL/IL.

Repeat-by:

1. First open a Cygwin console (not to be confused with Mintty) by
double-clicking bash.exe in C:\cygwin64\bin or by executing "cygstart
bash".
2a. run the following command at the last line of the terminal:

$ printf '\e[5M'

2b. run the following command at the last line of the terminal

$ printf '\e[5L'

The control sequence \e[<Pn>M (CSI <Pn> M) is the ANSI escape sequence
DL (DELETE LINE), which is supposed to delete the current line and the
following <Pn>-1 lines and scrolls up the subsequence lines. This
control function functions correctly when it is not at the last line
in the Cygwin console. However, if the current cursor position is
located at the last line, DL(<Pn>) of the Cygwin console wrongly
scrolls up the entire screen by <Pn> lines (instead of the subsequent
lines after the delete lines).

Likely, \e[<Pn>L is the ANSI escape sequence IL (INSERT LINE), which
is supposed to insert <Pn> new lines at the current line and to scroll
down the subsequent lines. However, when the cursor is at the last
line, IL of the Cygwin console again scrolls down the entire screen.

This behavior is also reproduced in Windows Terminal with a profile of
Cygwin executing bash.exe --login -i. This doesn't happen when we use
Mintty or other terminal emulators relying on the genuine Cygwin PTY.

Fix:

Any other terminals do not behave in this unintuitive way. When the
cursor is located at the last line, DL/IL should not scroll any lines
but should just clear only the last line.

--
Koichi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: In Cygwin console (not Mintty), escape sequences DL/IL at the last line misbehave
  2022-02-03 10:02 In Cygwin console (not Mintty), escape sequences DL/IL at the last line misbehave Koichi Murase
@ 2022-02-03 12:09 ` Takashi Yano
  2022-02-03 12:41   ` Koichi Murase
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Yano @ 2022-02-03 12:09 UTC (permalink / raw)
  To: cygwin

On Thu, 3 Feb 2022 19:02:14 +0900
Koichi Murase wrote:
> I'm not sure what this exactly is related to, but I guess pcon is
> closely related.

No, this is not related to pseudo console.

> Cygwin version:
> 
> I can reproduce it in Cygwin 3.2.0 and the latest 3.3.4 for both
> 64-bit and 32-bit versions. I usually set CYGWIN=disable_pcon, but
> this reproduces for both cases with and without disable_pcon.
> 
> I think I observed this behavior even earlier but don't exactly
> remember in which Cygwin version I first noticed this broken behavior.
> At least, this behavior has existed for a very long time. I have been
> thinking that there are a few people using the Cygwin console
> directly, but I recently noticed that it matters when I connect to
> Cygwin from Windows Terminal. This puts very hard limitations on
> implementing a line editor where the line editor does not know the
> absolute vertical position in the terminal screen so cannot predict
> the consequences of using DL/IL.
> 
> Repeat-by:
> 
> 1. First open a Cygwin console (not to be confused with Mintty) by
> double-clicking bash.exe in C:\cygwin64\bin or by executing "cygstart
> bash".
> 2a. run the following command at the last line of the terminal:
> 
> $ printf '\e[5M'
> 
> 2b. run the following command at the last line of the terminal
> 
> $ printf '\e[5L'
> 
> The control sequence \e[<Pn>M (CSI <Pn> M) is the ANSI escape sequence
> DL (DELETE LINE), which is supposed to delete the current line and the
> following <Pn>-1 lines and scrolls up the subsequence lines. This
> control function functions correctly when it is not at the last line
> in the Cygwin console. However, if the current cursor position is
> located at the last line, DL(<Pn>) of the Cygwin console wrongly
> scrolls up the entire screen by <Pn> lines (instead of the subsequent
> lines after the delete lines).
> 
> Likely, \e[<Pn>L is the ANSI escape sequence IL (INSERT LINE), which
> is supposed to insert <Pn> new lines at the current line and to scroll
> down the subsequent lines. However, when the cursor is at the last
> line, IL of the Cygwin console again scrolls down the entire screen.
> 
> This behavior is also reproduced in Windows Terminal with a profile of
> Cygwin executing bash.exe --login -i. This doesn't happen when we use
> Mintty or other terminal emulators relying on the genuine Cygwin PTY.
> 
> Fix:
> 
> Any other terminals do not behave in this unintuitive way. When the
> cursor is located at the last line, DL/IL should not scroll any lines
> but should just clear only the last line.

Thanks for the report.

I can reproduce the problem. I will submit a patch for this issue shortly.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: In Cygwin console (not Mintty), escape sequences DL/IL at the last line misbehave
  2022-02-03 12:09 ` Takashi Yano
@ 2022-02-03 12:41   ` Koichi Murase
  2022-02-03 15:12     ` Takashi Yano
  0 siblings, 1 reply; 4+ messages in thread
From: Koichi Murase @ 2022-02-03 12:41 UTC (permalink / raw)
  To: Takashi Yano; +Cc: cygwin

2022年2月3日(木) 21:10 Takashi Yano <takashi.yano@nifty.ne.jp>:

Thank you for your prompt reply and support!

> On Thu, 3 Feb 2022 19:02:14 +0900
> Koichi Murase wrote:
> > I'm not sure what this exactly is related to, but I guess pcon is
> > closely related.
>
> No, this is not related to pseudo console.

Also, thank you for the clarification. I am actually not good at the
structure of the TTY/console-related codes in Cygwin, but guessed you
have professional knowledge on it. I confess that I actually put these
words to catch your eye, though I haven't expected that you could
catch it in such a short time! Thank you very much!

--
Koichi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: In Cygwin console (not Mintty), escape sequences DL/IL at the last line misbehave
  2022-02-03 12:41   ` Koichi Murase
@ 2022-02-03 15:12     ` Takashi Yano
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Yano @ 2022-02-03 15:12 UTC (permalink / raw)
  To: cygwin

On Thu, 3 Feb 2022 21:41:29 +0900
Koichi Murase wrote:
> 2022年2月3日(木) 21:10 Takashi Yano <takashi.yano@nifty.ne.jp>:
> 
> Thank you for your prompt reply and support!
> 
> > On Thu, 3 Feb 2022 19:02:14 +0900
> > Koichi Murase wrote:
> > > I'm not sure what this exactly is related to, but I guess pcon is
> > > closely related.
> >
> > No, this is not related to pseudo console.
> 
> Also, thank you for the clarification. I am actually not good at the
> structure of the TTY/console-related codes in Cygwin, but guessed you
> have professional knowledge on it. I confess that I actually put these
> words to catch your eye, though I haven't expected that you could
> catch it in such a short time! Thank you very much!

Your bug reports are always very helpful because they point out
the essence of the problem. I appreciate indeed.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-03 15:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-03 10:02 In Cygwin console (not Mintty), escape sequences DL/IL at the last line misbehave Koichi Murase
2022-02-03 12:09 ` Takashi Yano
2022-02-03 12:41   ` Koichi Murase
2022-02-03 15:12     ` Takashi Yano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).