Project

General

Profile

Bug #13707

Updated by caspercg (Casper G) almost 7 years ago

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"` 

 


Back