Issue #13707 has been updated by nobu (Nobuyoshi Nakada).


Note: `cls` command on Windows clears the entire buffer, unlike "clear screen" of VT100.

----------------------------------------
Bug #13707: Windows ANSI escape sequences incorrectly positions cursor
https://bugs.ruby-lang.org/issues/13707#change-65624

* Author: caspercg (Casper Gripenberg)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.4.1p111 (2017-03-22 revision 58053) [i386-mingw32]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Positioning the cursor on Windows with the ANSI CSI n;m H sequence ("\e[n;mH") incorrectly moves the cursor relative to the console BUFFER, and not the actual console window as would be expected.

Doing `print "\e[1;1H"` should put the cursor in the top corner of the window, but instead it moves the cursor to the top of the internal DOS prompt buffer, and even moves the scrollbar to the top.

This is inconsistent with all other implementations of ANSI sequence processing on other platforms, and makes it hard to use simple cursor positioning sequences reliably on Windows.

The in-built `IO.console.winsize` does report the correct window size, which is good, but it's useless since the CSI H-sequence does not respect these size parameters.

Clear screen (CSI 2 J / `"\e[2J"`) also clears everything, instead of just the visible portion. CSI 3 J seems to be reserved for full clearing ([source](https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes)), but CSI 2 J should only clear the visible portion.


To reproduce:

1) Open a Windows command prompt with irb, where the buffer is larger than the window size (scrollbar visible)
2) Run `print "\e[1;1H"`





-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>