Project

General

Profile

Actions

Bug #13707

closed

Windows ANSI escape sequences incorrectly positions cursor

Added by caspercg (Casper G) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.1p111 (2017-03-22 revision 58053) [i386-mingw32]
[ruby-core:81883]

Description

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), 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"
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0