Ansi escape sequences not parsed under Win8.1 default cmd.exe
Under Windows 8.1 ANSI escape sequence contained in options.display strings are not parsed but instead are output as-is in the default cmd.exe terminal. I tracked it down to this line:
https://github.com/anseki/readline-sync/blob/master/lib/readline-sync.js#L171
By writing directly to the raw stdout file stream, parsing of ansi codes is circumvented, since this happens in the libuv layer which (which gets skipped). When I replace the line above with process.stdout.write(options.display); ANSI sequences are properly parsed+evaluated.
Hi @gcnm-pgeil, thank you for the reporting.
Yes, readlineSync deliberately ignores those. It uses native API to get TTY constantly. As you said, ANSI escape sequences are parsed by Node.js or the library for non-POSIX, but it is not completely. And also, Windows CMD has potential problems, I stopped using it to make TTY be raw mode. https://github.com/anseki/readline-sync/issues/14 I will update readlineSync if that situation changes. https://github.com/anseki/readline-sync/issues/22 https://github.com/anseki/readline-sync/issues/16
Hi @anseki,
alright. Until then I would recommend to place a prominent warning note in the README.md so that users which intend to use the (awesome) readlineSync module on the Windows platform are immediately aware of this issue. Because it took me a while to realize that this is due to windows terminal internals and not to a bug in my application or the module (since you use chalk in your examples, too).
Cheers ;)
You are right. I will update README soon. Thank you :smile: