0

Using process.stdout.write, the cursor is left at the end of the string you outputted.
However, when you write anything against the right border of the terminal, the cursor is placed at the beginning of the next line.

This causes a problem if you wish to give your application a background by filling the entire terminal, as it will scroll the window.

There is a workaround where you scroll back up one line, after having written to the lower right character slot, but that doesn't seem to be working on all platforms, namely cmd.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
CathrineVaage
  • 33
  • 1
  • 3

1 Answers1

0

From the description, it seems you are talking about ansi.js, which (as noted in ANSI escape sequences aren't printed to stdout on Windows in the accepted answer) relies upon a library such as libuv.

That library implements a moderate amount of escape sequences. But referring to the source-code for ansi.js, it uses escape[S for the scroll-up feature. That escape sequence is not handled by libuv.

A comment in libuv explains the reason why:

 * Normally cursor movement in windows is relative to the console screen buffer,
 * e.g. the application is allowed to overwrite the 'history'. This is very
 * inconvenient, it makes absolute cursor movement pretty useless. There is
 * also the concept of 'client rect' which is defined by the actual size of
 * the console window and the scroll position of the screen buffer, but it's
 * very volatile because it changes when the user scrolls.

In curses applications, this sort of thing is done by writing the character for the lower-right-corner in the next-to-last column, then using insert-character to put it in place. But neither ansi.js nor libuv implement this.

Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105