TIP #305: ANSI Escape Sequence Support for Windows's Console Channel Driver

Does someone know if this ever will be done?


DKF: It was withdrawn at the author's request when he worked out just how much work it was to bring it up to the point of being useful. (The Windows console is totally different to a Unix terminal.) In short, if it's going to be done then it's going to be done as a platform-specific extension, and do we really need to package it with Tcl itself at this stage?

APN: TWAPI provides commands [L1 ] to manipulate the console (cursor movement, colors etc.) albeit not in the form of ANSI sequences.

MHo I don't know why MS dropped Support for ANSI sequences. And TWAPI is a little overweight for creating a small text mode script with a few menus or so, and not cross platform. Curses Tk is totally outdated. Perhaps Consio could be a solution.


The situation here has completely changed now that Windows 10 (in its newer updates) actually supports ANSI/ECMA-48/VT100 escape sequences. So now you can get colours/etc on Windows in the same way as you do on Unix-like systems - just output the escape sequence. Except, you have to call SetConsoleMode to enable the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag before it will work. There are two other useful flags, ENABLE_VIRTUAL_TERMINAL_INPUT which makes it send escape sequences for key presses as well, and DISABLE_NEWLINE_AUTO_RETURN which changes the newline handling to be more compatible with Unix. The original plan in this withdrawn TIP now has little relevance (except for people who want this feature on older Windows versions – but it seems dubious to make a lot of complex effort to support a new feature on old Windows versions when newer versions support it in a far simpler way.) It would still make sense to enhance win/tclWinConsole.c – at a minimum, enhance ConsoleSetOptionProc and ConsoleGetOptionProc to support three these console mode options. Which assumably would require someone to submit a brand new TIP.